Skip to content

Commit

Permalink
Strip head first because of possible nested tags
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdavenport committed Oct 13, 2016
1 parent 42f4171 commit 85e572c
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -35,17 +35,19 @@ public function parse($input)
// Strip invalid UTF-8 characters.
$input = iconv("utf-8", "utf-8//IGNORE", $input);

// Convert <style>, <noscript> and <head> tags to <script> tags
// Remove anything between <head> and </head> tags. Do this first
// because there might be <script> or <style> tags nested inside.
$input = $this->removeBlocks($input, '<head>', '</head>');

// Convert <style> and <noscript> tags to <script> tags
// so we can remove them efficiently.
$search = array(
'<style', '</style',
'<noscript', '</noscript',
'<head', '</head',
);
$replace = array(
'<script', '</script',
'<script', '</script',
'<script', '</script',
);
$input = str_replace($search, $replace, $input);

Expand Down

0 comments on commit 85e572c

Please sign in to comment.