2
0
forked from Wavyzz/dolibarr

Qual: Add instanceof tests to help static typing analysis (#28696)

# Qual: Add instanceof tests to help static typing analysis

Added instanceof tests to help identify that properties exist.
This commit is contained in:
MDW
2024-03-07 23:09:25 +01:00
committed by GitHub
parent ff03f86a50
commit 79adb60cf5

View File

@@ -7630,9 +7630,14 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
$dom = new DOMDocument(null, 'UTF-8');
$dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
if (is_object($dom)) {
if ($dom instanceof DOMDocument) {
for ($els = $dom->getElementsByTagname('*'), $i = $els->length - 1; $i >= 0; $i--) {
for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
$el = $els->item($i);
if (!$el instanceof DOMElement) {
continue;
}
$attrs = $el->attributes;
for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
//var_dump($attrs->item($ii));
if (!empty($attrs->item($ii)->name)) {
if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {