mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Fixed content parsing break with line html comment
Fixes issues thrown in custom HMTL head & page content filtering when the content is comprised of only a single HTML comment. Adds tests to cover. For #2804
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php namespace BookStack\Util;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMNode;
|
||||
use DOMNodeList;
|
||||
use DOMXPath;
|
||||
|
||||
@@ -16,6 +15,7 @@ class HtmlContentFilter
|
||||
return $html;
|
||||
}
|
||||
|
||||
$html = '<body>' . $html . '</body>';
|
||||
libxml_use_internal_errors(true);
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
@@ -61,11 +61,10 @@ class HtmlContentFilter
|
||||
/**
|
||||
* Removed all of the given DOMNodes.
|
||||
*/
|
||||
static protected function removeNodes(DOMNodeList $nodes): void
|
||||
protected static function removeNodes(DOMNodeList $nodes): void
|
||||
{
|
||||
foreach ($nodes as $node) {
|
||||
$node->parentNode->removeChild($node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user