mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-15 15:32:28 +02:00
properly fix #2938
This commit is contained in:
parent
5cc7a3a852
commit
8b4b1fa9db
@ -200,7 +200,11 @@ var rawToRegexStr = function(s, anchor) {
|
|||||||
.replace(me.escape3, '')
|
.replace(me.escape3, '')
|
||||||
.replace(me.escape4, '[^ ]*?');
|
.replace(me.escape4, '[^ ]*?');
|
||||||
if ( anchor & 0x4 ) {
|
if ( anchor & 0x4 ) {
|
||||||
reStr = rawToRegexStr.reTextHostnameAnchor + reStr;
|
reStr = (
|
||||||
|
reStr.startsWith('\\.') ?
|
||||||
|
rawToRegexStr.reTextHostnameAnchor2 :
|
||||||
|
rawToRegexStr.reTextHostnameAnchor1
|
||||||
|
) + reStr;
|
||||||
} else if ( anchor & 0x2 ) {
|
} else if ( anchor & 0x2 ) {
|
||||||
reStr = '^' + reStr;
|
reStr = '^' + reStr;
|
||||||
}
|
}
|
||||||
@ -213,7 +217,8 @@ rawToRegexStr.escape1 = /[.+?${}()|[\]\\]/g;
|
|||||||
rawToRegexStr.escape2 = /\^/g;
|
rawToRegexStr.escape2 = /\^/g;
|
||||||
rawToRegexStr.escape3 = /^\*|\*$/g;
|
rawToRegexStr.escape3 = /^\*|\*$/g;
|
||||||
rawToRegexStr.escape4 = /\*/g;
|
rawToRegexStr.escape4 = /\*/g;
|
||||||
rawToRegexStr.reTextHostnameAnchor = '^[a-z-]+://(?:[^/?#]+\\.?)?';
|
rawToRegexStr.reTextHostnameAnchor1 = '^[a-z-]+://(?:[^/?#]+\\.)?';
|
||||||
|
rawToRegexStr.reTextHostnameAnchor2 = '^[a-z-]+://(?:[^/?#]+)?';
|
||||||
|
|
||||||
var filterFingerprinter = µb.CompiledLineWriter.fingerprint;
|
var filterFingerprinter = µb.CompiledLineWriter.fingerprint;
|
||||||
|
|
||||||
@ -450,7 +455,7 @@ FilterPlainHostname.prototype.match = function() {
|
|||||||
FilterPlainHostname.prototype.logData = function() {
|
FilterPlainHostname.prototype.logData = function() {
|
||||||
return {
|
return {
|
||||||
raw: '||' + this.s + '^',
|
raw: '||' + this.s + '^',
|
||||||
regex: rawToRegexStr(this.s, 0x4),
|
regex: rawToRegexStr(this.s + '^'),
|
||||||
compiled: this.compile()
|
compiled: this.compile()
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -627,13 +632,10 @@ FilterGenericHnAnchored.prototype.match = function(url) {
|
|||||||
return this.re.test(url);
|
return this.re.test(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
FilterGenericHnAnchored.prototype.reSourceOffset =
|
|
||||||
(new RegExp(rawToRegexStr.reTextHostnameAnchor)).source.length;
|
|
||||||
|
|
||||||
FilterGenericHnAnchored.prototype.logData = function() {
|
FilterGenericHnAnchored.prototype.logData = function() {
|
||||||
var out = {
|
var out = {
|
||||||
raw: '||' + this.s,
|
raw: '||' + this.s,
|
||||||
regex: this.re.source.slice(this.reSourceOffset),
|
regex: rawToRegexStr(this.s, this.anchor & ~0x4),
|
||||||
compiled: this.compile()
|
compiled: this.compile()
|
||||||
};
|
};
|
||||||
return out;
|
return out;
|
||||||
|
Loading…
Reference in New Issue
Block a user