Skip to content

Commit 80323ac

Browse files
authored
fix WysiwygFilter not removing all attributes
1 parent fa3a91d commit 80323ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/WysiwygFilter/WysiwygFilter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public function filter($html, $allowed = null)
5858
$config = $mapping[$nodeName];
5959
$DOMElement = $element->getNode(0);
6060

61-
foreach ($DOMElement->attributes as $attr) {
61+
// warning: attributes is a map that reindexes when removing an attribute
62+
// you need to copy it for iteraton
63+
foreach (iterator_to_array($DOMElement->attributes) as $attr) {
6264
if (false === array_key_exists($attr->nodeName, $config)) {
6365
$DOMElement->removeAttributeNode($attr);
6466
}

0 commit comments

Comments
 (0)