Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL

$code = $exception->getStatusCode();

return new Response($this->twig->render(
return Response::create($this->twig->render(
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
array(
'status_code' => $code,
Expand All @@ -60,7 +60,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
'logger' => $logger,
'currentContent' => $currentContent,
)
));
))->setCharset('UTF-8');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function testOnlyClearOwnOutputBuffers()
$request->headers->set('X-Php-Ob-Level', 1);

$controller = new ExceptionController($twig, false);
$controller->showAction($request, $flatten);
$response = $controller->showAction($request, $flatten);
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ public function showAction($token)

$code = $exception->getStatusCode();

return new Response($this->twig->render(
$template,
array(
return Response::create(
$this->twig->render($template, array(
'status_code' => $code,
'status_text' => Response::$statusTexts[$code],
'exception' => $exception,
'logger' => null,
'currentContent' => '',
)
), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

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

return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
$response = 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'));
}

return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
$response->setCharset('UTF-8');

return $response;
}

protected function getTemplate()
Expand Down
104 changes: 62 additions & 42 deletions src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@ public function panelAction(Request $request, $token)
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
}

return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
'token' => $token,
'profile' => $profile,
'collector' => $profile->getCollector($panel),
'panel' => $panel,
'page' => $page,
'request' => $request,
'templates' => $this->getTemplateManager()->getTemplates($profile),
'is_ajax' => $request->isXmlHttpRequest(),
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
'token' => $token,
'profile' => $profile,
'collector' => $profile->getCollector($panel),
'panel' => $panel,
'page' => $page,
'request' => $request,
'templates' => $this->getTemplateManager()->getTemplates($profile),
'is_ajax' => $request->isXmlHttpRequest(),
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

/**
Expand Down Expand Up @@ -147,9 +151,13 @@ public function infoAction($about)

$this->profiler->disable();

return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
'about' => $about,
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
'about' => $about,
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

/**
Expand Down Expand Up @@ -197,13 +205,17 @@ public function toolbarAction(Request $request, $token)
// the profiler is not enabled
}

return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
'position' => $position,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getTemplates($profile),
'profiler_url' => $url,
'token' => $token,
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
'position' => $position,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getTemplates($profile),
'profiler_url' => $url,
'token' => $token,
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

/**
Expand Down Expand Up @@ -241,15 +253,19 @@ public function searchBarAction(Request $request)
$token = $session->get('_profiler_search_token');
}

return new Response($this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
'token' => $token,
'ip' => $ip,
'method' => $method,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
'token' => $token,
'ip' => $ip,
'method' => $method,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

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

return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
'token' => $token,
'profile' => $profile,
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
'ip' => $ip,
'method' => $method,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
'panel' => null,
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
'token' => $token,
'profile' => $profile,
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
'ip' => $ip,
'method' => $method,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
'panel' => null,
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}

/**
Expand Down Expand Up @@ -364,7 +384,7 @@ public function phpinfoAction()
phpinfo();
$phpinfo = ob_get_clean();

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ public function panelAction($token)

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

return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array(
'request' => $request,
'router' => $profile->getCollector('router'),
'traces' => $matcher->getTraces($request->getPathInfo()),
)), 200, array('Content-Type' => 'text/html'));
return Response::create(
$this->twig->render('@WebProfiler/Router/panel.html.twig', array(
'request' => $request,
'router' => $profile->getCollector('router'),
'traces' => $matcher->getTraces($request->getPathInfo()),
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function testReturns404onTokenNotFound()

$response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
$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');
$this->assertEquals(404, $response->getStatusCode());
Expand Down