mirror of https://github.com/gorhill/uBlock.git
this fixes gorhill#142 and #1331
This commit is contained in:
parent
b19848583b
commit
cd8e0f87bd
|
@ -88,7 +88,7 @@ return {
|
||||||
|
|
||||||
// read-only
|
// read-only
|
||||||
systemSettings: {
|
systemSettings: {
|
||||||
compiledMagic: 'perhodsoahya',
|
compiledMagic: 'akjbdyreyxgm',
|
||||||
selfieMagic: 'spqmeuaftfra'
|
selfieMagic: 'spqmeuaftfra'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -571,6 +571,47 @@ FilterPlainHnAnchored.fromSelfie = function(s) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/142
|
||||||
|
|
||||||
|
var FilterPlainHnAnchoredHostname = function(s, hostname) {
|
||||||
|
this.s = s;
|
||||||
|
this.hostname = hostname;
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.prototype.match = function(url, tokenBeg) {
|
||||||
|
if ( pageHostnameRegister.slice(-this.hostname.length) !== this.hostname ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( url.substr(tokenBeg, this.s.length) !== this.s ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Valid only if hostname-valid characters to the left of token
|
||||||
|
var pos = url.indexOf('://');
|
||||||
|
return pos !== -1 &&
|
||||||
|
reURLPostHostnameAnchors.test(url.slice(pos + 3, tokenBeg)) === false;
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.fid = FilterPlainHnAnchoredHostname.prototype.fid = '||ah';
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.prototype.toString = function() {
|
||||||
|
return '||' + this.s;
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.prototype.toSelfie = function() {
|
||||||
|
return this.s + '\t' + this.hostname;
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.compile = function(details, hostname) {
|
||||||
|
return details.f + '\t' + hostname;
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterPlainHnAnchoredHostname.fromSelfie = function(s) {
|
||||||
|
var pos = s.indexOf('\t');
|
||||||
|
return new FilterPlainHnAnchoredHostname(s.slice(0, pos), s.slice(pos + 1));
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Generic filter
|
// Generic filter
|
||||||
|
|
||||||
var FilterGeneric = function(s, anchor) {
|
var FilterGeneric = function(s, anchor) {
|
||||||
|
@ -1141,6 +1182,9 @@ var getHostnameBasedFilterClass = function(details) {
|
||||||
if ( details.anchor > 0 ) {
|
if ( details.anchor > 0 ) {
|
||||||
return FilterPlainRightAnchoredHostname;
|
return FilterPlainRightAnchoredHostname;
|
||||||
}
|
}
|
||||||
|
if ( details.hostnameAnchored ) {
|
||||||
|
return FilterPlainHnAnchoredHostname;
|
||||||
|
}
|
||||||
if ( details.tokenBeg === 0 ) {
|
if ( details.tokenBeg === 0 ) {
|
||||||
return FilterPlainPrefix0Hostname;
|
return FilterPlainPrefix0Hostname;
|
||||||
}
|
}
|
||||||
|
@ -1592,6 +1636,7 @@ FilterContainer.prototype.factories = {
|
||||||
'a|': FilterPlainRightAnchored,
|
'a|': FilterPlainRightAnchored,
|
||||||
'a|h': FilterPlainRightAnchoredHostname,
|
'a|h': FilterPlainRightAnchoredHostname,
|
||||||
'||a': FilterPlainHnAnchored,
|
'||a': FilterPlainHnAnchored,
|
||||||
|
'||ah': FilterPlainHnAnchoredHostname,
|
||||||
'//': FilterRegex,
|
'//': FilterRegex,
|
||||||
'//h': FilterRegexHostname,
|
'//h': FilterRegexHostname,
|
||||||
'{h}': FilterHostnameDict,
|
'{h}': FilterHostnameDict,
|
||||||
|
|
Loading…
Reference in New Issue