diff options
| author | 2023-04-20 08:21:37 +0200 | |
|---|---|---|
| committer | 2023-04-20 08:21:37 +0200 | |
| commit | 5579dc88abee21adbb3654ea5e4b9941d12af6a6 (patch) | |
| tree | 1a3b885f209b0c6822114839a6ea09e9f114bffa /app/Models | |
| parent | ecd956c73608a699a8ebd177c68c740c4ca20af7 (diff) | |
Better XPath failure (#5317)
Report feeds as errored for more cases
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/Feed.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 0d7c35739..e96323d04 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -641,16 +641,19 @@ class FreshRSS_Feed extends Minz_Model { $doc = new DOMDocument(); $doc->recover = true; $doc->strictErrorChecking = false; + $ok = false; switch ($this->kind()) { case FreshRSS_Feed::KIND_HTML_XPATH: - $doc->loadHTML($html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING); + $ok = $doc->loadHTML($html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING) !== false; break; case FreshRSS_Feed::KIND_XML_XPATH: - $doc->loadXML($html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING); + $ok = $doc->loadXML($html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING) !== false; break; - default: - return null; + } + + if (!$ok) { + return null; } $xpath = new DOMXPath($doc); @@ -658,7 +661,7 @@ class FreshRSS_Feed extends Minz_Model { htmlspecialchars(@$xpath->evaluate('normalize-space(' . $xPathFeedTitle . ')'), ENT_COMPAT, 'UTF-8'); $view->rss_base = htmlspecialchars(trim($xpath->evaluate('normalize-space(//base/@href)')), ENT_COMPAT, 'UTF-8'); $nodes = $xpath->query($xPathItem); - if (empty($nodes)) { + if ($nodes === false || $nodes->length === 0) { return null; } |
