This commit is contained in:
gorhill 2016-10-03 23:41:23 -04:00
parent 90ec19d951
commit c956b93369
2 changed files with 23 additions and 13 deletions

View File

@ -94,8 +94,8 @@ return {
// read-only // read-only
systemSettings: { systemSettings: {
compiledMagic: 'ryegxvatkfxe', compiledMagic: 'lbmqiweqbvha',
selfieMagic: 'ryegxvatkfxe' selfieMagic: 'lbmqiweqbvha'
}, },
restoreBackupSettings: { restoreBackupSettings: {

View File

@ -858,14 +858,15 @@ FilterGenericHostname.fromSelfie = function(s) {
// whether the start of the match falls within the hostname part of the // whether the start of the match falls within the hostname part of the
// URL. // URL.
var FilterGenericHnAnchored = function(s) { var FilterGenericHnAnchored = function(s, anchor) {
this.s = s; this.s = s;
this.anchor = anchor;
this.re = null; this.re = null;
}; };
FilterGenericHnAnchored.prototype.match = function(url) { FilterGenericHnAnchored.prototype.match = function(url) {
if ( this.re === null ) { if ( this.re === null ) {
this.re = strToRegex('||' + this.s, 0); this.re = strToRegex('||' + this.s, this.anchor);
} }
var matchStart = url.search(this.re); var matchStart = url.search(this.re);
return matchStart !== -1 && isHnAnchored(url, matchStart); return matchStart !== -1 && isHnAnchored(url, matchStart);
@ -877,21 +878,22 @@ FilterGenericHnAnchored.prototype.rtfid = '||_';
FilterGenericHnAnchored.prototype.toSelfie = FilterGenericHnAnchored.prototype.toSelfie =
FilterGenericHnAnchored.prototype.rtCompile = function() { FilterGenericHnAnchored.prototype.rtCompile = function() {
return this.s; return this.s + '\t' + this.anchor;
}; };
FilterGenericHnAnchored.compile = function(details) { FilterGenericHnAnchored.compile = function(details) {
return details.f; return details.f + '\t' + details.anchor;
}; };
FilterGenericHnAnchored.fromSelfie = function(s) { FilterGenericHnAnchored.fromSelfie = function(s) {
return new FilterGenericHnAnchored(s); var pos = s.indexOf('\t');
return new FilterGenericHnAnchored(s.slice(0, pos), parseInt(s.slice(pos + 1), 10));
}; };
/******************************************************************************/ /******************************************************************************/
var FilterGenericHnAnchoredHostname = function(s, domainOpt) { var FilterGenericHnAnchoredHostname = function(s, anchor, domainOpt) {
FilterGenericHnAnchored.call(this, s); FilterGenericHnAnchored.call(this, s, anchor);
this.domainOpt = domainOpt; this.domainOpt = domainOpt;
this.hostnameTest = hostnameTestPicker(this); this.hostnameTest = hostnameTestPicker(this);
}; };
@ -909,16 +911,16 @@ FilterGenericHnAnchoredHostname.prototype.rtfid = '||_h';
FilterGenericHnAnchoredHostname.prototype.toSelfie = FilterGenericHnAnchoredHostname.prototype.toSelfie =
FilterGenericHnAnchoredHostname.prototype.rtCompile = function() { FilterGenericHnAnchoredHostname.prototype.rtCompile = function() {
return this.s + '\t' + this.domainOpt; return this.s + '\t' + this.anchor + '\t' + this.domainOpt;
}; };
FilterGenericHnAnchoredHostname.compile = function(details) { FilterGenericHnAnchoredHostname.compile = function(details) {
return details.f + '\t' + details.domainOpt; return details.f + '\t' + details.anchor + '\t' + details.domainOpt;
}; };
FilterGenericHnAnchoredHostname.fromSelfie = function(s) { FilterGenericHnAnchoredHostname.fromSelfie = function(s) {
var pos = s.indexOf('\t'); var fields = s.split('\t');
return new FilterGenericHnAnchoredHostname(s.slice(0, pos), s.slice(pos + 1)); return new FilterGenericHnAnchoredHostname(fields[0], parseInt(fields[1], 10), fields[2]);
}; };
/******************************************************************************/ /******************************************************************************/
@ -1749,6 +1751,10 @@ FilterContainer.prototype.getFilterClass = function(details) {
return FilterPlainLeftAnchoredHostname; return FilterPlainLeftAnchoredHostname;
} }
if ( details.anchor > 0 ) { if ( details.anchor > 0 ) {
// https://github.com/gorhill/uBlock/issues/1669
if ( details.hostnameAnchored ) {
return FilterGenericHnAnchoredHostname;
}
return FilterPlainRightAnchoredHostname; return FilterPlainRightAnchoredHostname;
} }
if ( details.hostnameAnchored ) { if ( details.hostnameAnchored ) {
@ -1776,6 +1782,10 @@ FilterContainer.prototype.getFilterClass = function(details) {
return FilterPlainLeftAnchored; return FilterPlainLeftAnchored;
} }
if ( details.anchor > 0 ) { if ( details.anchor > 0 ) {
// https://github.com/gorhill/uBlock/issues/1669
if ( details.hostnameAnchored ) {
return FilterGenericHnAnchored;
}
return FilterPlainRightAnchored; return FilterPlainRightAnchored;
} }
if ( details.hostnameAnchored ) { if ( details.hostnameAnchored ) {