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:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user