/**
* Provides filtering of tag attributes into accepted HTML.
*
* @param string $text
* The HTML text string to be filtered.
*
* @return string
* Filtered HTML with attributes filtered according to the settings.
*/
public function filterAttributes($text) { $restrictions =
$this->
getHTMLRestrictions();
$global_allowed_attributes =
array_filter($restrictions['allowed'
]['*'
]);
unset($restrictions['allowed'
]['*'
]);
// Apply attribute restrictions to tags.
$html_dom = Html::
load($text);
$xpath =
new \
DOMXPath($html_dom);
foreach ($restrictions['allowed'
] as $allowed_tag =>
$tag_attributes) { // By default, no attributes are allowed for a tag, but due to the
// globally allowed attributes, it is impossible for a tag to actually
// completely disallow attributes.
if ($tag_attributes === FALSE
) {