@@ 299-308 (lines=10) @@ | ||
296 | ||
297 | // Remove content before <!DOCTYPE.*> because otherwise the DOMDocument can not handle the input. |
|
298 | $isDOMDocumentCreatedWithDoctype = false; |
|
299 | if (\stripos($html, '<!DOCTYPE') !== false) { |
|
300 | $isDOMDocumentCreatedWithDoctype = true; |
|
301 | if ( |
|
302 | \preg_match('/(^.*?)<!(?:DOCTYPE)(?: [^>]*)?>/sui', $html, $matches_before_doctype) |
|
303 | && |
|
304 | \trim($matches_before_doctype[1]) |
|
305 | ) { |
|
306 | $html = \str_replace($matches_before_doctype[1], '', $html); |
|
307 | } |
|
308 | } |
|
309 | ||
310 | if ($this->keepBrokenHtml) { |
|
311 | $html = $this->keepBrokenHtml(\trim($html)); |
|
@@ 366-375 (lines=10) @@ | ||
363 | $this->isDOMDocumentCreatedWithFakeEndScript = true; |
|
364 | } |
|
365 | ||
366 | if (\stripos($html, '</html>') !== false) { |
|
367 | /** @noinspection NestedPositiveIfStatementsInspection */ |
|
368 | if ( |
|
369 | \preg_match('/<\/html>(.*?)/suiU', $html, $matches_after_html) |
|
370 | && |
|
371 | \trim($matches_after_html[1]) |
|
372 | ) { |
|
373 | $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html); |
|
374 | } |
|
375 | } |
|
376 | ||
377 | if (\strpos($html, '<script') !== false) { |
|
378 | $this->html5FallbackForScriptTags($html); |