1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00
This commit is contained in:
gorhill 2016-07-01 15:15:58 -04:00
parent 973d3e79c1
commit 0e244d9822

View File

@ -209,8 +209,10 @@ var strToRegex = function(s, anchor, flags) {
// https://www.loggly.com/blog/five-invaluable-techniques-to-improve-regex-performance/ // https://www.loggly.com/blog/five-invaluable-techniques-to-improve-regex-performance/
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions // https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
// Also: remove leading/trailing wildcards -- there is no point.
var reStr = s.replace(/[.+?${}()|[\]\\]/g, '\\$&') var reStr = s.replace(/[.+?${}()|[\]\\]/g, '\\$&')
.replace(/\^/g, '(?:[^%.0-9a-z_-]|$)') .replace(/\^/g, '(?:[^%.0-9a-z_-]|$)')
.replace(/^\*|\*$/g, '')
.replace(/\*/g, '[^ ]*?'); .replace(/\*/g, '[^ ]*?');
if ( anchor < 0 ) { if ( anchor < 0 ) {
@ -1991,10 +1993,6 @@ FilterContainer.prototype.compileHostnameOnlyFilter = function(parsed, out) {
FilterContainer.prototype.compileFilter = function(parsed, out) { FilterContainer.prototype.compileFilter = function(parsed, out) {
parsed.makeToken(); parsed.makeToken();
if ( parsed.token === '*' && parsed.hostnameAnchored ) {
console.error('FilterContainer.compileFilter("%s"): invalid filter', parsed.f);
return false;
}
var party = AnyParty; var party = AnyParty;
if ( parsed.firstParty !== parsed.thirdParty ) { if ( parsed.firstParty !== parsed.thirdParty ) {