forked from friendica/friendica-addons
[showmore] Use DOMDocument object instead of static call to loadHTML()
- Address https://github.com/friendica/friendica/issues/9498#issuecomment-751191039
This commit is contained in:
parent
7ce00592a2
commit
368a0d3f6c
|
@ -81,8 +81,9 @@ function get_body_length($body)
|
||||||
// We need to get rid of hidden tags (display: none)
|
// 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
|
// Get rid of the warning. It would be better to have some valid html as input
|
||||||
$dom = @DomDocument::loadHTML($body);
|
$doc = new DOMDocument();
|
||||||
$xpath = new DOMXPath($dom);
|
@$doc->loadHTML($body);
|
||||||
|
$xpath = new DOMXPath($doc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checking any possible syntax of the style attribute with xpath is impossible
|
* 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
|
// 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);
|
$string = strip_tags($string);
|
||||||
return strlen($string);
|
return strlen($string);
|
||||||
|
|
Loading…
Reference in a new issue