Merge pull request #1062 from MrPetovan/bug/fatal-errors
authorMichael Vogel <icarus@dabo.de>
Sun, 27 Dec 2020 05:58:43 +0000 (06:58 +0100)
committerGitHub <noreply@github.com>
Sun, 27 Dec 2020 05:58:43 +0000 (06:58 +0100)
[showmore] Use DOMDocument object instead of static call to loadHTML()

showmore/showmore.php

index 7583fd3..c0f581e 100644 (file)
@@ -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);