Quellcode durchsuchen

Fix DOM error while filtering retrieved full content (#8132)

```
PHP Fatal error: Uncaught Error: Couldn't fetch DOMElement in app/Models/Entry.php:998
```
Alexandre Alapetite vor 5 Monaten
Ursprung
Commit
5909cc5756
1 geänderte Dateien mit 6 neuen und 0 gelöschten Zeilen
  1. 6 0
      app/Models/Entry.php

+ 6 - 0
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 content
 						foreach ($filterednodes as $filterednode) {
@@ -973,6 +976,9 @@ HTML;
 							$filterednode->parentNode->removeChild($filterednode);
 						}
 					}
+					if ($node->parentNode === null) {
+						continue;
+					}
 					$html .= $doc->saveHTML($node) . "\n";
 				}
 			}