From bfd367ec38a0050278261b461a725683af1361ff Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Fri, 22 Dec 2017 14:52:54 -0300 Subject: Check for node type when scanning for better topCandidates --- src/Readability.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Readability.php b/src/Readability.php index f22c1e2..7ff302f 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -898,7 +898,8 @@ class Readability $scoreThreshold = $lastScore / 3; /* @var DOMElement $parentOfTopCandidate */ - while ($parentOfTopCandidate->nodeName !== 'body') { + // Check if we are actually dealing with a DOMNode and not a DOMDocument node or higher + while ($parentOfTopCandidate->nodeName !== 'body' && $parentOfTopCandidate->nodeType === XML_ELEMENT_NODE) { $parentScore = $parentOfTopCandidate->contentScore; if ($parentScore < $scoreThreshold) { break; -- cgit v1.2.3