Remove requirement for presence of type with `redirect=` option

Related issue:
- https://github.com/gorhill/uBlock/issues/3590

Since the `redirect=` option was refactored into a modifier
filter, presence of a type (`script`, `xhr`, etc.) is no
longer a requirement.
This commit is contained in:
Raymond Hill 2020-11-28 08:52:18 -05:00
parent f75040afb8
commit c6d0204b23
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 3 additions and 10 deletions

View File

@ -42,6 +42,7 @@ a*
! valid options ! valid options
$script,redirect=noop.js $script,redirect=noop.js
*$redirect=noop.js
*$empty *$empty
*$xhr,empty *$xhr,empty
*$xhr,redirect=empty *$xhr,redirect=empty
@ -91,9 +92,6 @@ $
! bad regex ! bad regex
/(abc|def/$xhr /(abc|def/$xhr
! can't redirect without type (except to `empty`)
*$redirect=noop.js
! non-redirectable types ! non-redirectable types
*$beacon,redirect-rule=empty *$beacon,redirect-rule=empty
*$ping,redirect-rule=empty *$ping,redirect-rule=empty

View File

@ -2383,18 +2383,13 @@ const NetOptionsIterator = class {
} }
} }
} }
// `redirect=`: requires at least one single redirectable type // `redirect=`: can't redirect non-redirectable types
{ {
let i = this.tokenPos[OPTTokenRedirect]; let i = this.tokenPos[OPTTokenRedirect];
if ( i === -1 ) { if ( i === -1 ) {
i = this.tokenPos[OPTTokenRedirectRule]; i = this.tokenPos[OPTTokenRedirectRule];
} }
if ( if ( i !== -1 && hasBits(allBits, OPTNonRedirectableType) ) {
i !== -1 && (
hasNoBits(allBits, OPTRedirectableType) ||
hasBits(allBits, OPTNonRedirectableType)
)
) {
optSlices[i] = OPTTokenInvalid; optSlices[i] = OPTTokenInvalid;
if ( this.interactive ) { if ( this.interactive ) {
this.parser.errorSlices(optSlices[i+1], optSlices[i+5]); this.parser.errorSlices(optSlices[i+1], optSlices[i+5]);