// Skip the empty text nodes inside tags.
continue;
} $tag =
$node->tagName;
// All attributes are already allowed on this tag, this is the most
// permissive configuration, no additional processing is required.
if (isset($restrictions['allowed'
][$tag]) &&
$restrictions['allowed'
][$tag] === TRUE
) { continue;
} if ($node->
hasAttributes()) { // If the tag is not yet present, prepare to add attribute restrictions.
// Otherwise, check if a more restrictive configuration (FALSE, meaning
// no attributes were allowed) is present: then override the existing
// value to prepare to add attribute restrictions.
if (!
isset($restrictions['allowed'
][$tag]) ||
$restrictions['allowed'
][$tag] === FALSE
) { $restrictions['allowed'
][$tag] =
[];
} // Iterate over any attributes, and mark them as allowed.
foreach ($node->attributes
as $name =>
$attribute) { // Only add specific attribute values if all values are not already