Allow regex in blacklist fixes #167 #542 (#546)

* Allow regex in blacklist fixes #167 #542
* Added protection against invalid regex causing failed initialization
* Added regex input validation
This commit is contained in:
Chad Bailey
2019-11-25 15:43:05 -06:00
committed by Ilya Grigorik
parent c4a26e3da2
commit ac7471edfc
3 changed files with 40 additions and 3 deletions

View File

@@ -275,7 +275,7 @@
// the first element of the target, which may not be the parent.
this.parent.insertBefore(fragment, this.parent.firstChild);
}
return wrapper;
return wrapper;
}
}
@@ -292,7 +292,16 @@
return;
}
var regexp = new RegExp(escapeStringRegExp(match));
if (match.startsWith('/')) {
try {
var regexp = new RegExp(match);
} catch(err) {
return;
}
} else {
var regexp = new RegExp(escapeStringRegExp(match));
}
if (regexp.test(location.href)) {
blacklisted = true;
return;