1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

#1056: code review

This commit is contained in:
gorhill 2015-12-13 11:03:13 -05:00
parent 64ef90a338
commit 933b6ad594

View File

@ -1303,7 +1303,8 @@ var trimChar = function(s, c) {
var FilterParser = function() { var FilterParser = function() {
this.reHasWildcard = /[\^\*]/; this.reHasWildcard = /[\^\*]/;
this.reCanTrimCarets = /^([^*]*|[^^]+\^[^^]+)$/; this.reCanTrimCarets1 = /^[^*]*$/;
this.reCanTrimCarets2 = /^\^?[^^]+[^^][^^]+\^?$/;
this.reHasUppercase = /[A-Z]/; this.reHasUppercase = /[A-Z]/;
this.reCleanupHostname = /^\|\|[.*]*/; this.reCleanupHostname = /^\|\|[.*]*/;
this.reIsolateHostname = /^([^\x00-\x24\x26-\x2C\x2F\x3A-\x5E\x60\x7B-\x7F]+)(.*)/; this.reIsolateHostname = /^([^\x00-\x24\x26-\x2C\x2F\x3A-\x5E\x60\x7B-\x7F]+)(.*)/;
@ -1568,7 +1569,7 @@ FilterParser.prototype.parse = function(raw) {
s = s.replace(/([^%0-9a-z])\*+$/, '$1'); s = s.replace(/([^%0-9a-z])\*+$/, '$1');
} }
// https://github.com/gorhill/uBlock/issues/1056 // https://github.com/gorhill/uBlock/issues/1056
if ( this.reCanTrimCarets.test(s) ) { if ( this.reCanTrimCarets1.test(s) && this.reCanTrimCarets2.test(s) ) {
s = trimChar(s, '^'); s = trimChar(s, '^');
} }
} }