From a356ced64664e0a5ff76152a84971e2e7b34d470 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Fri, 10 Mar 2023 22:17:31 +0100 Subject: [PATCH] fix potential infinite loop --- src/full_text_parser/readability/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/full_text_parser/readability/mod.rs b/src/full_text_parser/readability/mod.rs index 639bbad..ee919f6 100644 --- a/src/full_text_parser/readability/mod.rs +++ b/src/full_text_parser/readability/mod.rs @@ -355,7 +355,7 @@ impl Readability { // The scores shouldn't get too low. let score_threshold = last_score / 3.0; - while !Util::has_tag_name(parent_of_top_candidate.as_ref(), "BODY") { + while parent_of_top_candidate.is_some() && !Util::has_tag_name(parent_of_top_candidate.as_ref(), "BODY") { if parent_of_top_candidate .as_ref() .map(|n| Self::get_content_score(n).is_none())