Skip to content

Commit

Permalink
Fix incorrect insertion of toolbar when there are duplicate body tags.
Browse files Browse the repository at this point in the history
Insert the toolbar after the last close body tag, not the first. This
solves issues where script tags with sub-pages could cause the toolbar
to fail.

Fixes #117
  • Loading branch information
markstory committed Nov 22, 2014
1 parent 28bfd25 commit 3090231
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions View/Helper/HtmlToolbarHelper.php
Expand Up @@ -187,12 +187,16 @@ public function send() {
}
}
}
if (preg_match('#</head>#', $view->output)) {
$view->output = preg_replace('#</head>#', $head . "\n</head>", $view->output, 1);
$search = '</head>';
$pos = strpos($view->output, $search);
if ($pos !== false) {
$view->output = substr_replace($view->output, $head . "\n</head>", $pos, strlen($search));
}
$toolbar = $view->element('debug_toolbar', array('disableTimer' => true), array('plugin' => 'DebugKit'));
if (preg_match('#</body>#', $view->output)) {
$view->output = preg_replace('#</body>#', $toolbar . "\n</body>", $view->output, 1);
$search = '</body>';
$pos = strrpos($view->output, $search);
if ($pos !== false) {
$view->output = substr_replace($view->output, $toolbar . "\n</body>", $pos, strlen($search));
}
}

Expand Down

0 comments on commit 3090231

Please sign in to comment.