diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index f5a8287cd0..232416f3ab 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -45,7 +45,7 @@ const allowedAttribute = (attribute, allowedAttributeList) => { // Check if a regular expression validates the attribute. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) - .every(regex => regex.test(attributeName)) + .some(regex => regex.test(attributeName)) } export const DefaultAllowlist = { diff --git a/js/tests/unit/util/sanitizer.spec.js b/js/tests/unit/util/sanitizer.spec.js index 7379d221f4..28d624c878 100644 --- a/js/tests/unit/util/sanitizer.spec.js +++ b/js/tests/unit/util/sanitizer.spec.js @@ -23,6 +23,31 @@ describe('Sanitizer', () => { expect(result).not.toContain('href="javascript:alert(7)') }) + it('should sanitize template and work with multiple regex', () => { + const template = [ + '