From dcf215290ac66523d32fa2c8338449311addc261 Mon Sep 17 00:00:00 2001 From: Edan Date: Wed, 1 Apr 2020 19:24:25 +0700 Subject: [PATCH] fixes #93 stop endless loop when node parent is null --- src/Readability.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Readability.php b/src/Readability.php index 6bcbf78d..e7736492 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -1076,7 +1076,7 @@ private function rateNodes($nodes) $scoreThreshold = $lastScore / 3; /* @var DOMElement $parentOfTopCandidate */ - while ($parentOfTopCandidate->nodeName !== 'body') { + while (!is_null($parentOfTopCandidate) && $parentOfTopCandidate->nodeName !== 'body') { $parentScore = $parentOfTopCandidate->contentScore; if ($parentScore < $scoreThreshold) { break;