@@ -54,18 +54,21 @@ const NetFilteringResultCache = class {
5454 return this ;
5555 }
5656
57+ // https://github.com/gorhill/uBlock/issues/3619
58+ // Don't collapse redirected resources
5759 rememberResult ( fctxt , result ) {
5860 if ( fctxt . tabId <= 0 ) { return ; }
5961 if ( this . results . size === 0 ) {
6062 this . pruneAsync ( ) ;
6163 }
62- const key = fctxt . getDocHostname ( ) + ' ' + fctxt . type + ' ' + fctxt . url ;
64+ const key = ` ${ fctxt . getDocHostname ( ) } ${ fctxt . type } ${ fctxt . url } ` ;
6365 this . results . set ( key , {
64- result : result ,
66+ result,
67+ redirectURL : fctxt . redirectURL ,
6568 logData : fctxt . filter ,
6669 tstamp : Date . now ( )
6770 } ) ;
68- if ( result !== 1 ) { return ; }
71+ if ( result !== 1 || fctxt . redirectURL !== undefined ) { return ; }
6972 const now = Date . now ( ) ;
7073 this . blocked . set ( key , now ) ;
7174 this . hash = now ;
@@ -76,16 +79,17 @@ const NetFilteringResultCache = class {
7679 if ( this . blocked . size === 0 ) {
7780 this . pruneAsync ( ) ;
7881 }
82+ if ( fctxt . redirectURL !== undefined ) { return ; }
7983 const now = Date . now ( ) ;
8084 this . blocked . set (
81- fctxt . getDocHostname ( ) + ' ' + fctxt . type + ' ' + fctxt . url ,
85+ ` ${ fctxt . getDocHostname ( ) } ${ fctxt . type } ${ fctxt . url } ` ,
8286 now
8387 ) ;
8488 this . hash = now ;
8589 }
8690
87- forgetResult ( fctxt ) {
88- const key = `${ fctxt . getDocHostname ( ) } ${ fctxt . type } ${ fctxt . url } ` ;
91+ forgetResult ( docHostname , type , url ) {
92+ const key = `${ docHostname } ${ type } ${ url } ` ;
8993 this . results . delete ( key ) ;
9094 this . blocked . delete ( key ) ;
9195 }
@@ -171,7 +175,7 @@ const FrameStore = class {
171175 init ( frameURL ) {
172176 this . t0 = Date . now ( ) ;
173177 this . exceptCname = undefined ;
174- this . clickToLoad = 0 ;
178+ this . clickToLoad = false ;
175179 this . rawURL = frameURL ;
176180 if ( frameURL !== undefined ) {
177181 this . hostname = vAPI . hostnameFromURI ( frameURL ) ;
@@ -559,6 +563,7 @@ const PageStore = class {
559563 if ( cacheableResult ) {
560564 const entry = this . netFilteringCache . lookupResult ( fctxt ) ;
561565 if ( entry !== undefined ) {
566+ fctxt . redirectURL = entry . redirectURL ;
562567 fctxt . filter = entry . logData ;
563568 return entry . result ;
564569 }
@@ -607,11 +612,11 @@ const PageStore = class {
607612 }
608613 }
609614
610- // Click-to-load:
615+ // Click-to-load?
611616 // When frameId is not -1, the resource is always sub_frame.
612617 if ( result === 1 && fctxt . frameId !== - 1 ) {
613- const docStore = this . getFrameStore ( fctxt . frameId ) ;
614- if ( docStore !== null && docStore . clickToLoad !== 0 ) {
618+ const frameStore = this . getFrameStore ( fctxt . frameId ) ;
619+ if ( frameStore !== null && frameStore . clickToLoad ) {
615620 result = 2 ;
616621 if ( µb . logger . enabled ) {
617622 fctxt . setFilter ( {
@@ -623,13 +628,20 @@ const PageStore = class {
623628 }
624629 }
625630
631+ // https://github.com/gorhill/uBlock/issues/949
632+ // Redirect blocked request?
633+ if ( result === 1 && µb . hiddenSettings . ignoreRedirectFilters !== true ) {
634+ const redirectURL = µb . redirectEngine . toURL ( fctxt ) ;
635+ if ( redirectURL !== undefined ) {
636+ fctxt . redirectURL = redirectURL ;
637+ this . internalRedirectionCount += 1 ;
638+ }
639+ }
640+
626641 if ( cacheableResult ) {
627642 this . netFilteringCache . rememberResult ( fctxt , result ) ;
628- } else if (
629- result === 1 &&
630- this . collapsibleResources . has ( requestType )
631- ) {
632- this . netFilteringCache . rememberBlock ( fctxt , true ) ;
643+ } else if ( result === 1 && this . collapsibleResources . has ( requestType ) ) {
644+ this . netFilteringCache . rememberBlock ( fctxt ) ;
633645 }
634646
635647 return result ;
@@ -727,7 +739,12 @@ const PageStore = class {
727739 if ( frameStore === null ) {
728740 frameStore = this . setFrameURL ( frameId , frameURL ) ;
729741 }
730- frameStore . clickToLoad = Date . now ( ) ;
742+ this . netFilteringCache . forgetResult (
743+ this . tabHostname ,
744+ 'sub_frame' ,
745+ frameURL
746+ ) ;
747+ frameStore . clickToLoad = true ;
731748 }
732749
733750 shouldExceptCname ( fctxt ) {
@@ -776,24 +793,16 @@ const PageStore = class {
776793 // content script-side (i.e. `iframes` -- unlike `img`).
777794 if ( Array . isArray ( resources ) && resources . length !== 0 ) {
778795 for ( const resource of resources ) {
779- const result = this . filterRequest (
796+ this . filterRequest (
780797 fctxt . setType ( resource . type ) . setURL ( resource . url )
781798 ) ;
782- if ( result === 1 && µb . redirectEngine . toURL ( fctxt ) ) {
783- this . forgetBlockedResource ( fctxt ) ;
784- }
785799 }
786800 }
787801 if ( this . netFilteringCache . hash === response . hash ) { return ; }
788802 response . hash = this . netFilteringCache . hash ;
789803 response . blockedResources =
790804 this . netFilteringCache . lookupAllBlocked ( fctxt . getDocHostname ( ) ) ;
791805 }
792-
793- forgetBlockedResource ( fctxt ) {
794- if ( this . collapsibleResources . has ( fctxt . type ) === false ) { return ; }
795- this . netFilteringCache . forgetResult ( fctxt ) ;
796- }
797806} ;
798807
799808PageStore . prototype . cacheableResults = new Set ( [
0 commit comments