summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2017-12-22 14:52:54 -0300
committerAndres Rey <[email protected]>2017-12-22 14:52:54 -0300
commitbfd367ec38a0050278261b461a725683af1361ff (patch)
treea0d13b5b74977f7fdc201dfbe7310a22f28929ab /src
parent62094f4e9599856c2a2895c14bcddbc914322320 (diff)
Check for node type when scanning for better topCandidates
Diffstat (limited to 'src')
-rw-r--r--src/Readability.php3
1 files changed, 2 insertions, 1 deletions
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;