Selaa lähdekoodia

[WebProfilerBundle] removed the WDT on malformed HTML content

Fabien Potencier 14 vuotta sitten
vanhempi
commit
0834bf47dc

+ 4 - 3
src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

@@ -22,6 +22,9 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
  *
  * The handle method must be connected to the core.response event.
  *
+ * The WDT is only injected on well-formed HTML (with a proper </body> tag).
+ * This means that the WDT is never included in sub-requests or ESI requests.
+ *
  * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  */
 class WebDebugToolbarListener
@@ -83,9 +86,7 @@ class WebDebugToolbarListener
         $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, '</body>')) {
-            $content .= $toolbar;
-        } else {
+        if (false !== $pos = $posrFunction($content, '</body>')) {
             $content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
         }