From 0834bf47dcc7094538a6c958fd62a15049712be0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 19 Feb 2011 14:41:22 +0100 Subject: [PATCH] [WebProfilerBundle] removed the WDT on malformed HTML content --- .../Bundle/WebProfilerBundle/WebDebugToolbarListener.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php index 4bd4b9df57b3..ec13080905c8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php @@ -22,6 +22,9 @@ * * The handle method must be connected to the core.response event. * + * The WDT is only injected on well-formed HTML (with a proper tag). + * This means that the WDT is never included in sub-requests or ESI requests. + * * @author Fabien Potencier */ class WebDebugToolbarListener @@ -83,9 +86,7 @@ protected function injectToolbar(Response $response) $toolbar = "\n".str_replace("\n", '', $this->kernel->render('WebProfilerBundle:Profiler:toolbar', array('attributes' => array('token' => $response->headers->get('X-Debug-Token')))))."\n"; $content = $response->getContent(); - if (false === $pos = $posrFunction($content, '')) { - $content .= $toolbar; - } else { + if (false !== $pos = $posrFunction($content, '')) { $content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos); }