From 720f76fb5a75c976178a824cd061d4fe86bcb4a7 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 13 Dec 2015 10:26:55 -0500 Subject: [PATCH] this addresses #1056 --- src/js/static-net-filtering.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 096dffb44..ced1dcf18 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1303,6 +1303,7 @@ var trimChar = function(s, c) { var FilterParser = function() { this.reHasWildcard = /[\^\*]/; + this.reCanTrimCarets = /^([^*]*|[^^]+\^[^^]+)$/; this.reHasUppercase = /[A-Z]/; this.reCleanupHostname = /^\|\|[.*]*/; this.reIsolateHostname = /^([^\x00-\x24\x26-\x2C\x2F\x3A-\x5E\x60\x7B-\x7F]+)(.*)/; @@ -1566,7 +1567,10 @@ FilterParser.prototype.parse = function(raw) { if ( s.slice(-1) === '*' ) { s = s.replace(/([^%0-9a-z])\*+$/, '$1'); } - s = trimChar(s, '^'); + // https://github.com/gorhill/uBlock/issues/1056 + if ( this.reCanTrimCarets.test(s) ) { + s = trimChar(s, '^'); + } } // nothing left?