Skip to content

Commit

Permalink
Merge pull request #144 from adnedelcu/feature/allow-global-attributes
Browse files Browse the repository at this point in the history
Allow setting of global attributes
  • Loading branch information
mewebstudio committed Oct 27, 2020
2 parents da76c87 + 6f58e96 commit d9c3bd8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Purifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ private function addCustomAttributes(array $attributes, HTMLPurifier_HTMLDefinit
$attrName = $required ? $attribute[1] . '*' : $attribute[1];
$validValues = $attribute[2];

if ($onElement === '*') {
$def = $validValues;
if (is_string($validValues)) {
$def = new $validValues();
}

if ($def instanceof \HTMLPurifier_AttrDef) {
$definition->info_global_attr[$attrName] = $def;
}

continue;
}

$definition->addAttribute($onElement, $attrName, $validValues);
}

Expand Down

0 comments on commit d9c3bd8

Please sign in to comment.