mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Consider an empty pattern with anchors to be dubious
Related issue: - https://github.com/ryanbr/fanboy-adblock/issues/1384
This commit is contained in:
parent
7b55f0fbf1
commit
3789259fc9
2 changed files with 18 additions and 9 deletions
|
@ -252,16 +252,16 @@ CodeMirror.defineMode('ubo-static-filtering', function() {
|
||||||
if ( parser.category === parser.CATComment ) {
|
if ( parser.category === parser.CATComment ) {
|
||||||
return colorCommentSpan(stream);
|
return colorCommentSpan(stream);
|
||||||
}
|
}
|
||||||
if ( (parser.slices[parserSlot] & parser.BITIgnore) !== 0 ) {
|
|
||||||
stream.pos += parser.slices[parserSlot+2];
|
|
||||||
parserSlot += 3;
|
|
||||||
return 'comment';
|
|
||||||
}
|
|
||||||
if ( (parser.slices[parserSlot] & parser.BITError) !== 0 ) {
|
if ( (parser.slices[parserSlot] & parser.BITError) !== 0 ) {
|
||||||
stream.pos += parser.slices[parserSlot+2];
|
stream.pos += parser.slices[parserSlot+2];
|
||||||
parserSlot += 3;
|
parserSlot += 3;
|
||||||
return 'error';
|
return 'error';
|
||||||
}
|
}
|
||||||
|
if ( (parser.slices[parserSlot] & parser.BITIgnore) !== 0 ) {
|
||||||
|
stream.pos += parser.slices[parserSlot+2];
|
||||||
|
parserSlot += 3;
|
||||||
|
return 'comment';
|
||||||
|
}
|
||||||
if ( parser.category === parser.CATStaticExtFilter ) {
|
if ( parser.category === parser.CATStaticExtFilter ) {
|
||||||
return colorExtSpan(stream);
|
return colorExtSpan(stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,7 +636,11 @@ const Parser = class {
|
||||||
this.toASCII(true) === false
|
this.toASCII(true) === false
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.markSpan(this.patternSpan, BITError);
|
this.markSlices(
|
||||||
|
this.patternLeftAnchorSpan.i,
|
||||||
|
this.optionsAnchorSpan.i,
|
||||||
|
BITError
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.netOptionsIterator.init();
|
this.netOptionsIterator.init();
|
||||||
}
|
}
|
||||||
|
@ -908,12 +912,17 @@ const Parser = class {
|
||||||
// Examples of dubious filter content:
|
// Examples of dubious filter content:
|
||||||
// - Spaces characters
|
// - Spaces characters
|
||||||
// - Single character other than `*` wildcard
|
// - Single character other than `*` wildcard
|
||||||
|
// - Zero-length pattern with anchors
|
||||||
|
// https://github.com/ryanbr/fanboy-adblock/issues/1384
|
||||||
patternIsDubious() {
|
patternIsDubious() {
|
||||||
return hasBits(this.patternBits, BITSpace) || (
|
return hasBits(this.patternBits, BITSpace) || (
|
||||||
this.patternBits !== BITAsterisk &&
|
this.patternBits !== BITAsterisk &&
|
||||||
this.optionsSpan.len === 0 &&
|
this.optionsSpan.len === 0 && (
|
||||||
|
this.patternSpan.len === 0 &&
|
||||||
|
this.patternLeftAnchorSpan.len !== 0 ||
|
||||||
this.patternSpan.len === 3 &&
|
this.patternSpan.len === 3 &&
|
||||||
this.slices[this.patternSpan.i+2] === 1
|
this.slices[this.patternSpan.i+2] === 1
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue