this addresses a part of #498

This commit is contained in:
gorhill 2015-02-26 18:08:42 -05:00
parent 5291e3e27a
commit 25c0333fbe
2 changed files with 19 additions and 5 deletions

View file

@ -85,8 +85,8 @@ return {
// read-only
systemSettings: {
compiledMagic: 'dgycowxrdjuf',
selfieMagic: 'dmakcrbecglp'
compiledMagic: 'riimnrvxjchy',
selfieMagic: 'spqmeuaftfra'
},
// EasyList, EasyPrivacy and many others have an 4-day update period,

View file

@ -1453,6 +1453,9 @@ var trimChar = function(s, c) {
var FilterParser = function() {
this.reHasWildcard = /[\^\*]/;
this.reHasUppercase = /[A-Z]/;
this.reCleanupHostname = /^\|\|[.*]*/;
this.reIsolateHostname = /^([^\x00-\x24\x26-\x2C\x2F\x3A-\x5E\x60\x7B-\x7F]+)(.*)/;
this.reHasUnicode = /[^\x00-\x7F]/;
this.hostnames = [];
this.notHostnames = [];
this.reset();
@ -1588,10 +1591,12 @@ FilterParser.prototype.parseOptions = function(s) {
/******************************************************************************/
FilterParser.prototype.parse = function(s) {
FilterParser.prototype.parse = function(raw) {
// important!
this.reset();
var s = raw;
// plain hostname?
if ( reHostnameRule.test(s) ) {
this.f = s;
@ -1631,10 +1636,19 @@ FilterParser.prototype.parse = function(s) {
return this;
}
// hostname anchoring
// hostname-anchored
if ( s.lastIndexOf('||', 0) === 0 ) {
this.hostnameAnchored = true;
s = s.slice(2);
// cleanup: `||example.com`, `||*.example.com^`, `||.example.com/*`
s = s.replace(this.reCleanupHostname, '');
// convert hostname to punycode if needed
if ( this.reHasUnicode.test(s) ) {
var matches = this.reIsolateHostname.exec(s);
if ( matches && matches.length === 3 ) {
s = punycode.toASCII(matches[1]) + matches[2];
//console.debug('µBlock.staticNetFilteringEngine/FilterParser.parse():', raw, '=', s);
}
}
}
// left-anchored