From c6d0204b236449a8fe055c17c0b10af0446cb9ec Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 28 Nov 2020 08:52:18 -0500 Subject: [PATCH] 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. --- docs/tests/static-filtering-parser-checklist.txt | 4 +--- src/js/static-filtering-parser.js | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/tests/static-filtering-parser-checklist.txt b/docs/tests/static-filtering-parser-checklist.txt index c88599983..e7b5b5496 100644 --- a/docs/tests/static-filtering-parser-checklist.txt +++ b/docs/tests/static-filtering-parser-checklist.txt @@ -42,6 +42,7 @@ a* ! valid options $script,redirect=noop.js +*$redirect=noop.js *$empty *$xhr,empty *$xhr,redirect=empty @@ -91,9 +92,6 @@ $ ! bad regex /(abc|def/$xhr -! can't redirect without type (except to `empty`) -*$redirect=noop.js - ! non-redirectable types *$beacon,redirect-rule=empty *$ping,redirect-rule=empty diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 0c2d76577..5b9fdcf21 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -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]; if ( i === -1 ) { i = this.tokenPos[OPTTokenRedirectRule]; } - if ( - i !== -1 && ( - hasNoBits(allBits, OPTRedirectableType) || - hasBits(allBits, OPTNonRedirectableType) - ) - ) { + if ( i !== -1 && hasBits(allBits, OPTNonRedirectableType) ) { optSlices[i] = OPTTokenInvalid; if ( this.interactive ) { this.parser.errorSlices(optSlices[i+1], optSlices[i+5]);