A free, self-hostable news aggregator…
Fix DOM error while filtering retrieved full content (#8132)
Alexandre Alapetite5909cc575616
diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex d4f5016f0..13fcae4cf 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -961,6 +961,9 @@ HTML;if ($nodes != false) {$filter_xpath = $path_entries_filter === '' ? '' : (new Gt\CssXPath\Translator($path_entries_filter, 'descendant-or-self::'))->asXPath();foreach ($nodes as $node) {+ if (!($node instanceof DOMElement)) {+ continue;+ }if ($filter_xpath !== '' && ($filterednodes = $xpath->query($filter_xpath, $node)) !== false) {// Remove unwanted elements once before sanitizing, for CSS selectors to also match original contentforeach ($filterednodes as $filterednode) {@@ -973,6 +976,9 @@ HTML;$filterednode->parentNode->removeChild($filterednode);}}+ if ($node->parentNode === null) {+ continue;+ }$html .= $doc->saveHTML($node) . "\n";}}