2
0
Fork 0
mirror of https://github.com/discourse/wp-discourse.git synced 2025-10-03 08:59:21 +08:00

Remove html and body tags that are added to the DOM Document

This commit is contained in:
scossar 2017-12-27 12:08:14 -08:00
parent 9ff609617e
commit 0a1f7b5580

View file

@ -107,6 +107,11 @@ class TemplateFunctions {
// Restore the previous value of libxml_use_internal_errors.
libxml_use_internal_errors( $use_internal_errors );

return $doc->saveHTML( $doc->documentElement );
$parsed = $doc->saveHTML( $doc->documentElement );

// Remove DOCTYPE, html, and body tags that have been added to the DOMDocument.
$parsed = preg_replace( '~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $parsed );

return $parsed;
}
}