mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-24 22:25:09 +03:00
Merge pull request #2075 from FathiBenNasr/fix/htmlutils-data-attributes
HtmlUtils: strip every data-* attribute, not just the first one
This commit is contained in:
commit
8a8304e81a
1 changed files with 9 additions and 2 deletions
|
|
@ -160,13 +160,20 @@ abstract class HtmlUtils
|
|||
|
||||
// Remove all remaining data-* attributes
|
||||
foreach ($xpath->query('//*[@*[starts-with(name(), "data-")]]') as $oElement) {
|
||||
$sTagNameLower = \strtolower($oElement->nodeName);
|
||||
if ($oElement->hasAttributes()) {
|
||||
// DOMNamedNodeMap is live: removing the attribute the foreach is
|
||||
// currently on ends the iteration, so exactly one data-* was
|
||||
// removed per element however many it carried. Collect the
|
||||
// names first, then remove.
|
||||
$aNames = [];
|
||||
foreach ($oElement->attributes as $oAttr) {
|
||||
if ('data-' === \substr(\strtolower($oAttr->nodeName), 0, 5)) {
|
||||
$oElement->removeAttribute($oAttr->nodeName);
|
||||
$aNames[] = $oAttr->nodeName;
|
||||
}
|
||||
}
|
||||
foreach ($aNames as $sName) {
|
||||
$oElement->removeAttribute($sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue