From 2596c9703462f327e20e0464cff26c5ed1f091da Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 6 Oct 2021 00:23:14 +0300 Subject: [PATCH] util/sanitizer.js: use `Array.every()` (#35120) --- js/src/util/sanitizer.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index e27961e9a3..f5a8287cd0 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -43,16 +43,9 @@ const allowedAttribute = (attribute, allowedAttributeList) => { return true } - const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) - // Check if a regular expression validates the attribute. - for (const element of regExp) { - if (element.test(attributeName)) { - return true - } - } - - return false + return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) + .every(regex => regex.test(attributeName)) } export const DefaultAllowlist = { -- 2.47.2