Skip to content

Commit 0834bf4

Browse files
committed
[WebProfilerBundle] removed the WDT on malformed HTML content
1 parent 2c45611 commit 0834bf4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*
2323
* The handle method must be connected to the core.response event.
2424
*
25+
* The WDT is only injected on well-formed HTML (with a proper </body> tag).
26+
* This means that the WDT is never included in sub-requests or ESI requests.
27+
*
2528
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
2629
*/
2730
class WebDebugToolbarListener
@@ -83,9 +86,7 @@ protected function injectToolbar(Response $response)
8386
$toolbar = "\n".str_replace("\n", '', $this->kernel->render('WebProfilerBundle:Profiler:toolbar', array('attributes' => array('token' => $response->headers->get('X-Debug-Token')))))."\n";
8487
$content = $response->getContent();
8588

86-
if (false === $pos = $posrFunction($content, '</body>')) {
87-
$content .= $toolbar;
88-
} else {
89+
if (false !== $pos = $posrFunction($content, '</body>')) {
8990
$content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
9091
}
9192

0 commit comments

Comments
 (0)