From 904aa87e2aacb5fbfbb79ea702891e5be72d4b55 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 7 Dec 2020 11:12:41 -0500 Subject: [PATCH] Fix various regression in behavior of `redirect-rule=` Related issue: - https://github.com/uBlockOrigin/uBlock-issues/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. --- src/js/redirect-engine.js | 1 + src/js/static-net-filtering.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index 1b8780996..dc89afe67 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -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); diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 75fb0d663..2f0a494cd 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -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; }