Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ca7fc9

Browse filesBrowse files
Revert "bug #13715 Enforce UTF-8 charset for core controllers (WouterJ)"
This reverts commit 463b24b, reversing changes made to c475704.
1 parent e020f74 commit 6ca7fc9
Copy full SHA for 6ca7fc9

File tree

Expand file treeCollapse file tree

6 files changed

+57
-88
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+57
-88
lines changed

‎src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
5151

5252
$code = $exception->getStatusCode();
5353

54-
return Response::create($this->twig->render(
54+
return new Response($this->twig->render(
5555
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
5656
array(
5757
'status_code' => $code,
@@ -60,7 +60,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
6060
'logger' => $logger,
6161
'currentContent' => $currentContent,
6262
)
63-
))->setCharset('UTF-8');
63+
));
6464
}
6565

6666
/**

‎src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function testOnlyClearOwnOutputBuffers()
3939
$request->headers->set('X-Php-Ob-Level', 1);
4040

4141
$controller = new ExceptionController($twig, false);
42-
$response = $controller->showAction($request, $flatten);
43-
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
42+
$controller->showAction($request, $flatten);
4443
}
4544
}

‎src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php
+7-12Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ public function showAction($token)
6262

6363
$code = $exception->getStatusCode();
6464

65-
return Response::create(
66-
$this->twig->render($template, array(
65+
return new Response($this->twig->render(
66+
$template,
67+
array(
6768
'status_code' => $code,
6869
'status_text' => Response::$statusTexts[$code],
6970
'exception' => $exception,
7071
'logger' => null,
7172
'currentContent' => '',
72-
)),
73-
200,
74-
array('Content-Type' => 'text/html')
75-
)->setCharset('UTF-8');
73+
)
74+
), 200, array('Content-Type' => 'text/html'));
7675
}
7776

7877
/**
@@ -98,14 +97,10 @@ public function cssAction($token)
9897
if (!$this->templateExists($template)) {
9998
$handler = new ExceptionHandler();
10099

101-
$response = new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
102-
} else {
103-
$response = new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
100+
return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
104101
}
105102

106-
$response->setCharset('UTF-8');
107-
108-
return $response;
103+
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
109104
}
110105

111106
protected function getTemplate()

‎src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
+42-62Lines changed: 42 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,16 @@ public function panelAction(Request $request, $token)
9999
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
100100
}
101101

102-
return Response::create(
103-
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
104-
'token' => $token,
105-
'profile' => $profile,
106-
'collector' => $profile->getCollector($panel),
107-
'panel' => $panel,
108-
'page' => $page,
109-
'request' => $request,
110-
'templates' => $this->getTemplateManager()->getTemplates($profile),
111-
'is_ajax' => $request->isXmlHttpRequest(),
112-
)),
113-
200,
114-
array('Content-Type' => 'text/html')
115-
)->setCharset('UTF-8');
102+
return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
103+
'token' => $token,
104+
'profile' => $profile,
105+
'collector' => $profile->getCollector($panel),
106+
'panel' => $panel,
107+
'page' => $page,
108+
'request' => $request,
109+
'templates' => $this->getTemplateManager()->getTemplates($profile),
110+
'is_ajax' => $request->isXmlHttpRequest(),
111+
)), 200, array('Content-Type' => 'text/html'));
116112
}
117113

118114
/**
@@ -151,13 +147,9 @@ public function infoAction($about)
151147

152148
$this->profiler->disable();
153149

154-
return Response::create(
155-
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
156-
'about' => $about,
157-
)),
158-
200,
159-
array('Content-Type' => 'text/html')
160-
)->setCharset('UTF-8');
150+
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
151+
'about' => $about,
152+
)), 200, array('Content-Type' => 'text/html'));
161153
}
162154

163155
/**
@@ -205,17 +197,13 @@ public function toolbarAction(Request $request, $token)
205197
// the profiler is not enabled
206198
}
207199

208-
return Response::create(
209-
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
210-
'position' => $position,
211-
'profile' => $profile,
212-
'templates' => $this->getTemplateManager()->getTemplates($profile),
213-
'profiler_url' => $url,
214-
'token' => $token,
215-
)),
216-
200,
217-
array('Content-Type' => 'text/html')
218-
)->setCharset('UTF-8');
200+
return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
201+
'position' => $position,
202+
'profile' => $profile,
203+
'templates' => $this->getTemplateManager()->getTemplates($profile),
204+
'profiler_url' => $url,
205+
'token' => $token,
206+
)), 200, array('Content-Type' => 'text/html'));
219207
}
220208

221209
/**
@@ -253,19 +241,15 @@ public function searchBarAction(Request $request)
253241
$token = $session->get('_profiler_search_token');
254242
}
255243

256-
return Response::create(
257-
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
258-
'token' => $token,
259-
'ip' => $ip,
260-
'method' => $method,
261-
'url' => $url,
262-
'start' => $start,
263-
'end' => $end,
264-
'limit' => $limit,
265-
)),
266-
200,
267-
array('Content-Type' => 'text/html')
268-
)->setCharset('UTF-8');
244+
return new Response($this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
245+
'token' => $token,
246+
'ip' => $ip,
247+
'method' => $method,
248+
'url' => $url,
249+
'start' => $start,
250+
'end' => $end,
251+
'limit' => $limit,
252+
)), 200, array('Content-Type' => 'text/html'));
269253
}
270254

271255
/**
@@ -295,22 +279,18 @@ public function searchResultsAction(Request $request, $token)
295279
$end = $request->query->get('end', null);
296280
$limit = $request->query->get('limit');
297281

298-
return Response::create(
299-
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
300-
'token' => $token,
301-
'profile' => $profile,
302-
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
303-
'ip' => $ip,
304-
'method' => $method,
305-
'url' => $url,
306-
'start' => $start,
307-
'end' => $end,
308-
'limit' => $limit,
309-
'panel' => null,
310-
)),
311-
200,
312-
array('Content-Type' => 'text/html')
313-
)->setCharset('UTF-8');
282+
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
283+
'token' => $token,
284+
'profile' => $profile,
285+
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
286+
'ip' => $ip,
287+
'method' => $method,
288+
'url' => $url,
289+
'start' => $start,
290+
'end' => $end,
291+
'limit' => $limit,
292+
'panel' => null,
293+
)), 200, array('Content-Type' => 'text/html'));
314294
}
315295

316296
/**
@@ -384,7 +364,7 @@ public function phpinfoAction()
384364
phpinfo();
385365
$phpinfo = ob_get_clean();
386366

387-
return Response::create($phpinfo, 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8');
367+
return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
388368
}
389369

390370
/**

‎src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ public function panelAction($token)
6868

6969
$request = $profile->getCollector('request');
7070

71-
return Response::create(
72-
$this->twig->render('@WebProfiler/Router/panel.html.twig', array(
73-
'request' => $request,
74-
'router' => $profile->getCollector('router'),
75-
'traces' => $matcher->getTraces($request->getPathInfo()),
76-
)),
77-
200,
78-
array('Content-Type' => 'text/html')
79-
)->setCharset('UTF-8');
71+
return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array(
72+
'request' => $request,
73+
'router' => $profile->getCollector('router'),
74+
'traces' => $matcher->getTraces($request->getPathInfo()),
75+
)), 200, array('Content-Type' => 'text/html'));
8076
}
8177
}

‎src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function testReturns404onTokenNotFound()
6969

7070
$response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
7171
$this->assertEquals(200, $response->getStatusCode());
72-
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
7372

7473
$response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
7574
$this->assertEquals(404, $response->getStatusCode());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.