Skip to content

Commit

Permalink
Fix various regression in behavior of redirect-rule=
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#1388

Fixed the special `none` redirect resource no longer being
enforced.

Fixed the enforcement of `important` redirect rules over
exceptions and non-important ones.
  • Loading branch information
gorhill committed Dec 7, 2020
1 parent 5d7a5a5 commit 904aa87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/js/redirect-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ RedirectEngine.prototype.tokenToURL = function(
/******************************************************************************/

RedirectEngine.prototype.hasToken = function(token) {
if ( token === 'none' ) { return true; }
const asDataURI = token.charCodeAt(0) === 0x25 /* '%' */;
if ( asDataURI ) {
token = token.slice(1);
Expand Down
9 changes: 7 additions & 2 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -4261,8 +4261,13 @@ FilterContainer.parseRedirectRequestValue = function(modifier) {
};

FilterContainer.compareRedirectRequests = function(a, b) {
if ( (a.bits & AllowAction) !== 0 ) { return -1; }
if ( (b.bits & AllowAction) !== 0 ) { return 1; }
const abits = a.bits, bbits = b.bits;
if ( abits !== bbits ) {
if ( (abits & Important) !== 0 ) { return 1; }
if ( (bbits & Important) !== 0 ) { return -1; }
if ( (abits & AllowAction) !== 0 ) { return -1; }
if ( (bbits & AllowAction) !== 0 ) { return 1; }
}
const { token: atok, priority: aint } =
FilterContainer.parseRedirectRequestValue(a.modifier);
if ( µb.redirectEngine.hasToken(atok) === false ) { return -1; }
Expand Down

0 comments on commit 904aa87

Please sign in to comment.