From c8c144b663b8dc9a6fcbbaa9f434b429f6d76cc2 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 31 Dec 2021 14:18:16 -0500 Subject: [PATCH] Also test legitimacy of popup tab against last clicked link Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1912 Related commit: - https://github.com/gorhill/uBlock/commit/7713597e3e3ecf5c03c70f56bdb989e7d78956e8 In above related commit, uBO was modified to cache the URL of the last clicked link, and to use this cached URL to test for the legitimacy of the newly opened tab. The current commit add back a test against the URL of the last clicked link to avoid false positives when navigating from within the newly opened tab. --- src/js/tab.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/tab.js b/src/js/tab.js index 7e6640c4f..9a9ac8c62 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -355,8 +355,14 @@ const onPopupUpdated = (( ) => { let popupType = 'popup', result = 0; // https://github.com/gorhill/uBlock/issues/2919 - // - If the target tab matches a clicked link, assume it's legit. - if ( areDifferentURLs(targetURL, openerDetails.trustedURL) ) { + // If the target tab matches a clicked link, assume it's legit. + // https://github.com/uBlockOrigin/uBlock-issues/issues/1912 + // If the target also matches the last clicked link, assume it's + // legit. + if ( + areDifferentURLs(targetURL, openerDetails.trustedURL) && + areDifferentURLs(targetURL, µb.maybeGoodPopup.url) + ) { result = popupMatch(fctxt, rootOpenerURL, localOpenerURL, targetURL); }