diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-01-07 23:07:51 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-02-17 22:33:54 +0300 |
commit | 6c464938039e4fb23af4a35146250da9e1630de4 (patch) | |
tree | 0558838aed3c15ef3688461ee8a99b8d4b84ddb6 /js/src/tools | |
parent | f737c73a27965a22c98bf31ea3f03e76ca4b1be0 (diff) |
Use regex.test() when we want to check for a Boolean. (#29969)
Diffstat (limited to 'js/src/tools')
-rw-r--r-- | js/src/tools/sanitizer.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/js/src/tools/sanitizer.js b/js/src/tools/sanitizer.js index 0e83bde477..f108c66d5a 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 Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) + return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue) } return true @@ -80,8 +80,8 @@ function allowedAttribute(attr, allowedAttributeList) { const regExp = allowedAttributeList.filter((attrRegex) => attrRegex instanceof RegExp) // Check if a regular expression validates the attribute. - for (let i = 0, l = regExp.length; i < l; i++) { - if (attrName.match(regExp[i])) { + for (let i = 0, len = regExp.length; i < len; i++) { + if (regExp[i].test(attrName)) { return true } } |