From 0aae101196fed17de8cdee516cdcbf77f49a82d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 11 Nov 2022 12:46:23 +0200 Subject: [PATCH] Improve cookie-sandbox behavior when getting attachments via WBP Previously cookies only got attached on the initial request but not on any redirect and subsequent request. This may have been the cause for many reports of import failures behind proxies in the past. --- chrome/content/zotero/xpcom/cookieSandbox.js | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/cookieSandbox.js b/chrome/content/zotero/xpcom/cookieSandbox.js index 7987db04f5..9302e04016 100755 --- a/chrome/content/zotero/xpcom/cookieSandbox.js +++ b/chrome/content/zotero/xpcom/cookieSandbox.js @@ -317,10 +317,17 @@ Zotero.CookieSandbox.Observer = new function() { this.trackedInterfaceRequestors.splice(i, 1); this.trackedInterfaceRequestorSandboxes.splice(i, 1); i--; - } else if(ir == notificationCallbacks) { - // We are tracking this interface requestor - trackedBy = this.trackedInterfaceRequestorSandboxes[i]; - break; + } else { + let tracked = ir === notificationCallbacks; + try { + tracked = ir === notificationCallbacks.getInterface(Ci.nsIWebBrowserPersist); + } catch (e) { } + + if (tracked) { + // We are tracking this interface requestor + trackedBy = this.trackedInterfaceRequestorSandboxes[i]; + break; + } } } @@ -350,12 +357,6 @@ Zotero.CookieSandbox.Observer = new function() { notificationCallbacks.QueryInterface(Components.interfaces.nsIXMLHttpRequest); tested = true; } catch(e) {} - if(!tested) { - try { - notificationCallbacks.QueryInterface(Components.interfaces.nsIWebBrowserPersist); - tested = true; - } catch(e) {} - } } } }