From 6d2135b65c2e70870d0f7bf2856f8208e3c83dbd Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Wed, 15 May 2013 18:33:29 +0200 Subject: [PATCH] force the Content-Type to html in the web profiler controllers --- .../Controller/ExceptionController.php | 6 ++-- .../Controller/ProfilerController.php | 32 +++++++++---------- .../Controller/RouterController.php | 4 +-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php index 64108d58ad695..6d10ab641b72d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php @@ -50,7 +50,7 @@ public function showAction($token) if (!$this->twig->getLoader()->exists($template)) { $handler = new ExceptionHandler(); - return new Response($handler->getContent($exception)); + return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html')); } $code = $exception->getStatusCode(); @@ -64,7 +64,7 @@ public function showAction($token) 'logger' => null, 'currentContent' => '', ) - )); + ), 200, array('Content-Type' => 'text/html')); } /** @@ -87,7 +87,7 @@ public function cssAction($token) return new Response($handler->getStylesheet($exception)); } - return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig')); + return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, 'text/css'); } protected function getTemplate() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 1b2d8ded1f204..4b0ba07ce9d34 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -61,7 +61,7 @@ public function homeAction() { $this->profiler->disable(); - return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10))); + return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)), 302, array('Content-Type' => 'text/html')); } /** @@ -82,7 +82,7 @@ public function panelAction(Request $request, $token) $page = $request->query->get('page', 'home'); if (!$profile = $this->profiler->loadProfile($token)) { - return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token))); + return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token)), 200, array('Content-Type' => 'text/html')); } if (!$profile->hasCollector($panel)) { @@ -98,7 +98,7 @@ public function panelAction(Request $request, $token) 'request' => $request, 'templates' => $this->getTemplateManager()->getTemplates($profile), 'is_ajax' => $request->isXmlHttpRequest(), - ))); + )), 200, array('Content-Type' => 'text/html')); } /** @@ -134,7 +134,7 @@ public function purgeAction() $this->profiler->disable(); $this->profiler->purge(); - return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'purge'))); + return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'purge')), 302, array('Content-Type' => 'text/html')); } /** @@ -151,14 +151,14 @@ public function importAction(Request $request) $file = $request->files->get('file'); if (empty($file) || !$file->isValid()) { - return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'upload_error'))); + return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'upload_error')), 302, array('Content-Type' => 'text/html')); } if (!$profile = $this->profiler->import(file_get_contents($file->getPathname()))) { - return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'already_exists'))); + return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'already_exists')), 302, array('Content-Type' => 'text/html')); } - return new RedirectResponse($this->generator->generate('_profiler', array('token' => $profile->getToken()))); + return new RedirectResponse($this->generator->generate('_profiler', array('token' => $profile->getToken())), 302, array('Content-Type' => 'text/html')); } /** @@ -174,7 +174,7 @@ public function infoAction($about) return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array( 'about' => $about - ))); + )), 200, array('Content-Type' => 'text/html')); } /** @@ -195,13 +195,13 @@ public function toolbarAction(Request $request, $token) } if (null === $token) { - return new Response(); + return new Response('', 200, array('Content-Type' => 'text/html')); } $this->profiler->disable(); if (!$profile = $this->profiler->loadProfile($token)) { - return new Response(); + return new Response('', 200, array('Content-Type' => 'text/html')); } // the toolbar position (top, bottom, normal, or null -- use the configuration) @@ -222,7 +222,7 @@ public function toolbarAction(Request $request, $token) 'templates' => $this->getTemplateManager()->getTemplates($profile), 'profiler_url' => $url, 'token' => $token, - ))); + )), 200, array('Content-Type' => 'text/html')); } /** @@ -262,7 +262,7 @@ public function searchBarAction(Request $request) 'start' => $start, 'end' => $end, 'limit' => $limit, - ))); + )), 200, array('Content-Type' => 'text/html')); } /** @@ -297,7 +297,7 @@ public function searchResultsAction(Request $request, $token) 'end' => $end, 'limit' => $limit, 'panel' => null, - ))); + )), 200, array('Content-Type' => 'text/html')); } /** @@ -330,7 +330,7 @@ public function searchAction(Request $request) } if (!empty($token)) { - return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token))); + return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token)), 302, array('Content-Type' => 'text/html')); } $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end); @@ -343,7 +343,7 @@ public function searchAction(Request $request) 'start' => $start, 'end' => $end, 'limit' => $limit, - ))); + )), 302, array('Content-Type' => 'text/html')); } /** @@ -359,7 +359,7 @@ public function phpinfoAction() phpinfo(); $phpinfo = ob_get_clean(); - return new Response($phpinfo); + return new Response($phpinfo, 200, array('Content-Type' => 'text/html')); } /** diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index 430b3873887d3..1ff9961679ce7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -53,7 +53,7 @@ public function panelAction($token) $this->profiler->disable(); if (null === $this->matcher || null === $this->routes) { - return new Response('The Router is not enabled.'); + return new Response('The Router is not enabled.', 200, array('Content-Type' => 'text/html')); } $profile = $this->profiler->loadProfile($token); @@ -68,6 +68,6 @@ public function panelAction($token) 'request' => $request, 'router' => $profile->getCollector('router'), 'traces' => $matcher->getTraces($request->getPathInfo()), - ))); + )), 200, array('Content-Type' => 'text/html')); } }