0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 23:02:45 +00:00

Stop evaluation tests as soon as one returns true

This commit is contained in:
G.Ambatte
2024-07-04 09:32:29 +12:00
parent 2fc5bcabb8
commit b638cca547

View File

@@ -31,9 +31,12 @@ function safeHTML(htmlString) {
// Check remaining elements for blacklisted attributes // Check remaining elements for blacklisted attributes
if(element.hasAttributes()){ if(element.hasAttributes()){
for (const attribute of element.attributes){ for (const attribute of element.attributes){
let result = false; for (const test of blacklistAttrs) {
blacklistAttrs.forEach((test)=>{result ||= test(attribute);}); if(test(attribute)){
if(result) element.removeAttribute(attribute.localName); element.removeAttribute(attribute.localName);
break;
};
};
}; };
}; };
}); });