Skip to content

Commit d037640

Browse files
committed
Added regexp to remove all scripts elements
1 parent 01b29d0 commit d037640

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Embed/Url.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public function getHtmlContent () {
154154
$response = preg_replace('/<head[^>]*>/','<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">', $response);
155155
}
156156

157+
//Remove all script elements (thanks https://github.com/jasny)
158+
$response = preg_replace('%<script\b(?:"(?:[^"\\\\\\\\]++|\\\\\\\\.)*+"|\'(?:[^\\\\\\\\]++|\\\\\\\\.)*+\'|[^>"]++)*>(?:"(?:[^"\\\\\\\\]++|\\\\\\\\.)*+"|\'(?:[^\\\\\\\\]++|\\\\\\\\.)*+\'|//.*?\n|/\*(?:[^\*]++|\*)*?\*/|[^<"/]++|/|(?R)|<)*?</\s*script>%si', '', $response);
159+
157160
$this->htmlContent->loadHTML($response);
158161
libxml_use_internal_errors($errors);
159162

0 commit comments

Comments
 (0)