From 86f2c014592dfacdceef70ed05070b2548f74805 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 9 May 2020 16:50:47 +0300 Subject: [PATCH] Partially revert "Use regex.test() when we want to check for a Boolean. (#29969)" This partially reverts commit 6c464938039e4fb23af4a35146250da9e1630de4. --- js/src/tools/sanitizer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/tools/sanitizer.js b/js/src/tools/sanitizer.js index 0c3d4813b9..4ff3f7aa68 100644 --- a/js/src/tools/sanitizer.js +++ b/js/src/tools/sanitizer.js @@ -71,7 +71,7 @@ function allowedAttribute(attr, allowedAttributeList) { if (allowedAttributeList.indexOf(attrName) !== -1) { if (uriAttrs.indexOf(attrName) !== -1) { - return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue) + return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) } return true @@ -81,7 +81,7 @@ function allowedAttribute(attr, allowedAttributeList) { // Check if a regular expression validates the attribute. for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attrName)) { + if (attrName.match(regExp[i])) { return true } }