From 3e0581faaa9b9e308f68bcbdb742adb1a669496d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=83=C2=BCnzli?= Date: Sun, 12 Oct 2008 00:02:55 +0330 Subject: [PATCH] Bug 459041 - jar: URLs break sss_serializeSessionStorage (and thus SessionStore) --- .../sessionstore/src/nsSessionStore.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 95e6f0e54ee..74586192cb3 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1116,26 +1116,27 @@ SessionStoreService.prototype = { let hasContent = false; for (let i = 0; i < aHistory.count; i++) { - let uri = aHistory.getEntryAtIndex(i, false).URI.clone(); + let uri = aHistory.getEntryAtIndex(i, false).URI; // sessionStorage is saved per domain (cf. nsDocShell::GetSessionStorageForURI) - if (uri instanceof Ci.nsIURL) - uri.path = ""; - if (storageData[uri.spec] || !(aFullData || this._checkPrivacyLevel(uri.schemeIs("https")))) + let domain = uri.spec; + try { + if (uri.host) + domain = uri.prePath; + } + catch (ex) { /* this throws for host-less URIs (such as about: or jar:) */ } + if (storageData[domain] || !(aFullData || this._checkPrivacyLevel(uri.schemeIs("https")))) continue; - let storage, storageItemCount; + let storage, storageItemCount = 0; try { storage = aDocShell.getSessionStorageForURI(uri); storageItemCount = storage.length; - if (storageItemCount == 0) - continue; } - catch (ex) { - // sessionStorage might throw if it's turned off, see bug 458954 + catch (ex) { /* sessionStorage might throw if it's turned off, see bug 458954 */ } + if (storageItemCount == 0) continue; - } - let data = storageData[uri.spec] = {}; + let data = storageData[domain] = {}; for (let j = 0; j < storageItemCount; j++) { try { let key = storage.key(j);