Revert "bug #13715 Enforce UTF-8 charset for core controllers (WouterJ)"

This reverts commit 463b24b27c, reversing
changes made to c475704c8f.
This commit is contained in:
Nicolas Grekas 2015-03-11 15:41:28 +01:00
parent e020f749f0
commit 6ca7fc9460
6 changed files with 57 additions and 88 deletions

View File

@ -51,7 +51,7 @@ class ExceptionController
$code = $exception->getStatusCode(); $code = $exception->getStatusCode();
return Response::create($this->twig->render( return new Response($this->twig->render(
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug), (string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
array( array(
'status_code' => $code, 'status_code' => $code,
@ -60,7 +60,7 @@ class ExceptionController
'logger' => $logger, 'logger' => $logger,
'currentContent' => $currentContent, 'currentContent' => $currentContent,
) )
))->setCharset('UTF-8'); ));
} }
/** /**

View File

@ -39,7 +39,6 @@ class ExceptionControllerTest extends TestCase
$request->headers->set('X-Php-Ob-Level', 1); $request->headers->set('X-Php-Ob-Level', 1);
$controller = new ExceptionController($twig, false); $controller = new ExceptionController($twig, false);
$response = $controller->showAction($request, $flatten); $controller->showAction($request, $flatten);
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
} }
} }

View File

@ -62,17 +62,16 @@ class ExceptionController
$code = $exception->getStatusCode(); $code = $exception->getStatusCode();
return Response::create( return new Response($this->twig->render(
$this->twig->render($template, array( $template,
array(
'status_code' => $code, 'status_code' => $code,
'status_text' => Response::$statusTexts[$code], 'status_text' => Response::$statusTexts[$code],
'exception' => $exception, 'exception' => $exception,
'logger' => null, 'logger' => null,
'currentContent' => '', 'currentContent' => '',
)), )
200, ), 200, array('Content-Type' => 'text/html'));
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -98,14 +97,10 @@ class ExceptionController
if (!$this->templateExists($template)) { if (!$this->templateExists($template)) {
$handler = new ExceptionHandler(); $handler = new ExceptionHandler();
$response = new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
} else {
$response = new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
} }
$response->setCharset('UTF-8'); return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
return $response;
} }
protected function getTemplate() protected function getTemplate()

View File

@ -99,20 +99,16 @@ class ProfilerController
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token)); throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
} }
return Response::create( return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array( 'token' => $token,
'token' => $token, 'profile' => $profile,
'profile' => $profile, 'collector' => $profile->getCollector($panel),
'collector' => $profile->getCollector($panel), 'panel' => $panel,
'panel' => $panel, 'page' => $page,
'page' => $page, 'request' => $request,
'request' => $request, 'templates' => $this->getTemplateManager()->getTemplates($profile),
'templates' => $this->getTemplateManager()->getTemplates($profile), 'is_ajax' => $request->isXmlHttpRequest(),
'is_ajax' => $request->isXmlHttpRequest(), )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -151,13 +147,9 @@ class ProfilerController
$this->profiler->disable(); $this->profiler->disable();
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array( 'about' => $about,
'about' => $about, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -205,17 +197,13 @@ class ProfilerController
// the profiler is not enabled // the profiler is not enabled
} }
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( 'position' => $position,
'position' => $position, 'profile' => $profile,
'profile' => $profile, 'templates' => $this->getTemplateManager()->getTemplates($profile),
'templates' => $this->getTemplateManager()->getTemplates($profile), 'profiler_url' => $url,
'profiler_url' => $url, 'token' => $token,
'token' => $token, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -253,19 +241,15 @@ class ProfilerController
$token = $session->get('_profiler_search_token'); $token = $session->get('_profiler_search_token');
} }
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array( 'token' => $token,
'token' => $token, 'ip' => $ip,
'ip' => $ip, 'method' => $method,
'method' => $method, 'url' => $url,
'url' => $url, 'start' => $start,
'start' => $start, 'end' => $end,
'end' => $end, 'limit' => $limit,
'limit' => $limit, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -295,22 +279,18 @@ class ProfilerController
$end = $request->query->get('end', null); $end = $request->query->get('end', null);
$limit = $request->query->get('limit'); $limit = $request->query->get('limit');
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array( 'token' => $token,
'token' => $token, 'profile' => $profile,
'profile' => $profile, 'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end), 'ip' => $ip,
'ip' => $ip, 'method' => $method,
'method' => $method, 'url' => $url,
'url' => $url, 'start' => $start,
'start' => $start, 'end' => $end,
'end' => $end, 'limit' => $limit,
'limit' => $limit, 'panel' => null,
'panel' => null, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -384,7 +364,7 @@ class ProfilerController
phpinfo(); phpinfo();
$phpinfo = ob_get_clean(); $phpinfo = ob_get_clean();
return Response::create($phpinfo, 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8'); return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
} }
/** /**

View File

@ -68,14 +68,10 @@ class RouterController
$request = $profile->getCollector('request'); $request = $profile->getCollector('request');
return Response::create( return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array(
$this->twig->render('@WebProfiler/Router/panel.html.twig', array( 'request' => $request,
'request' => $request, 'router' => $profile->getCollector('router'),
'router' => $profile->getCollector('router'), 'traces' => $matcher->getTraces($request->getPathInfo()),
'traces' => $matcher->getTraces($request->getPathInfo()), )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
} }

View File

@ -69,7 +69,6 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
$response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found'); $response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
$response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound'); $response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());