1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

Fix validation of redirect rules with empty resource

The `empty` resource is a special case, it does not
require a network type to be present to be valid.
This commit is contained in:
Raymond Hill 2020-06-15 07:40:18 -04:00
parent cb5437b161
commit f8b0ee0fdc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1044,6 +1044,10 @@ const Parser = class {
return true;
}
hasFlavor(bits) {
return hasBits(this.flavorBits, bits);
}
isException() {
return hasBits(this.flavorBits, BITFlavorException);
}
@ -2108,8 +2112,19 @@ const NetOptionsIterator = class {
);
}
}
// `redirect` requires one single network type
if ( redirectIndex !== -1 && typeCount !== 1 && networkTypeCount !== 1 ) {
// `redirect` requires one single network type, EXCEPT for when we
// redirect to `empty`, in which case it is allowed to not have any
// network type specified.
if (
( redirectIndex !== -1 ) &&
( typeCount !== 1 || networkTypeCount !== 1 ) &&
( typeCount !== 0 || networkTypeCount !== 0 ||
this.parser.raw.slice(
this.parser.slices[optSlices[redirectIndex+4]+1],
this.parser.slices[optSlices[redirectIndex+5]+1]
) !== 'empty'
)
) {
optSlices[redirectIndex] = OPTTokenInvalid;
if ( this.interactive ) {
this.parser.markSlices(