diff --git a/src/js/html-filtering.js b/src/js/html-filtering.js
index 0260830fa..91cf126af 100644
--- a/src/js/html-filtering.js
+++ b/src/js/html-filtering.js
@@ -309,9 +309,11 @@
// TODO: Mind negated hostnames, they are currently discarded.
- for ( const { hn } of parser.extOptions() ) {
+ for ( const { hn, not, bad } of parser.extOptions() ) {
+ if ( bad ) { continue; }
let kind = 0;
if ( exception ) {
+ if ( not ) { continue; }
kind |= 0b01;
}
if ( compiled.charCodeAt(0) === 0x7B /* '{' */ ) {
diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js
index e04a4e0d2..94682f8f6 100644
--- a/src/js/scriptlet-filtering.js
+++ b/src/js/scriptlet-filtering.js
@@ -305,7 +305,8 @@
// Ignore instances of exception filter with negated hostnames,
// because there is no way to create an exception to an exception.
- for ( const { hn, not } of parser.extOptions() ) {
+ for ( const { hn, not, bad } of parser.extOptions() ) {
+ if ( bad ) { continue; }
let kind = 0;
if ( exception ) {
if ( not ) { continue; }
diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js
index f64260747..47b78ae0b 100644
--- a/src/js/static-filtering-parser.js
+++ b/src/js/static-filtering-parser.js
@@ -483,7 +483,7 @@ const Parser = class {
this.skipUntilNot(
this.patternSpan.i,
lastPatternSlice,
- BITHostname
+ BITHostname | BITAsterisk
) === lastPatternSlice
) {
this.patternRightAnchorSpan.i = lastPatternSlice;
@@ -623,15 +623,22 @@ const Parser = class {
analyzeDomainList(from, to, bitSeparator, optionBits) {
if ( from >= to ) { return; }
let beg = from;
+ // Dangling leading separator?
+ if ( hasBits(this.slices[beg], bitSeparator) ) {
+ this.markSlices(beg, beg + 3, BITError);
+ beg += 3;
+ }
while ( beg < to ) {
let end = this.skipUntil(beg, to, bitSeparator);
- if ( end === -1 ) { end = to; }
+ if ( end < to && this.slices[end+2] !== 1 ) {
+ this.markSlices(end, end + 3, BITError);
+ }
if ( this.analyzeDomain(beg, end, optionBits) === false ) {
this.markSlices(beg, end, BITError);
}
beg = end + 3;
}
- // Dangling separator at the end?
+ // Dangling trailing separator?
if ( hasBits(this.slices[to-3], bitSeparator) ) {
this.markSlices(to - 3, to, BITError);
}
@@ -815,18 +822,18 @@ const Parser = class {
}
skipUntil(from, to, bits) {
- let i = from + 3;
- for (;;) {
- if ( i === to || (this.slices[i] & bits) !== 0 ) { break; }
+ let i = from;
+ while ( i < to ) {
+ if ( (this.slices[i] & bits) !== 0 ) { break; }
i += 3;
}
return i;
}
skipUntilNot(from, to, bits) {
- let i = from + 3;
- for (;;) {
- if ( i === to || (this.slices[i] & bits) === 0 ) { break; }
+ let i = from;
+ while ( i < to ) {
+ if ( (this.slices[i] & bits) === 0 ) { break; }
i += 3;
}
return i;
@@ -2300,16 +2307,9 @@ const ExtOptionsIterator = class {
if ( hasBits(slices[i], BITComma) ) { break; }
i += 3;
}
+ if ( i === i0 ) { value.bad = true; }
value.hn = parser.raw.slice(slices[i0+1], slices[i+1]);
- if ( i < this.r ) {
- if ( interactive && (slices[i+2] !== 1 || (i+3) === this.r) ) {
- parser.markSlices(i, i+3, BITError);
- }
- i += 3;
- }
- if ( interactive && value.bad ) {
- parser.markSlices(this.l, i, BITError);
- }
+ if ( i < this.r ) { i += 3; }
this.l = i;
return this;
}