Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Fixes Script tags that contain closing HTML tags #49

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DeferParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ protected function setOrRemoveAttribute($node, $attr, $value)
protected function script_encode($html)
{
return preg_replace_callback('/(<script[^>]*>)(.*?)(<\/script>)/si', function ($matches) {
if (!preg_match('/type=/i', $matches[1]) || strpos($matches[1], 'text/javascript') !== false) {
if (!preg_match('/<\/[^>]*>/i', $matches[2]) && (!preg_match('/type=/i', $matches[1]) || strpos($matches[1], 'text/javascript') !== false)) {
return $matches[0];
}

Expand Down