From 368a0d3f6c11a2507231a9e900f6c1abaa5e68e8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Dec 2020 18:30:21 -0500 Subject: [PATCH] [showmore] Use DOMDocument object instead of static call to loadHTML() - Address https://github.com/friendica/friendica/issues/9498#issuecomment-751191039 --- showmore/showmore.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/showmore/showmore.php b/showmore/showmore.php index 7583fd33..c0f581ec 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -81,8 +81,9 @@ function get_body_length($body) // We need to get rid of hidden tags (display: none) // Get rid of the warning. It would be better to have some valid html as input - $dom = @DomDocument::loadHTML($body); - $xpath = new DOMXPath($dom); + $doc = new DOMDocument(); + @$doc->loadHTML($body); + $xpath = new DOMXPath($doc); /* * Checking any possible syntax of the style attribute with xpath is impossible @@ -96,7 +97,7 @@ function get_body_length($body) } } // Now we can get the body of our HTML DomDocument, it contains only what is visible - $string = $dom->saveHTML(); + $string = $doc->saveHTML(); $string = strip_tags($string); return strlen($string); -- 2.39.5