[
Bug 671520] Port
Bug 668646 [Invalid cookie hosts causes sessionstore to stop updating]. r=Neil
--- a/suite/common/src/nsSessionStore.js
+++ b/suite/common/src/nsSessionStore.js
@@ -2015,47 +2015,52 @@ SessionStoreService.prototype = {
var jscookies = {};
var _this = this;
// MAX_EXPIRY should be 2^63-1, but JavaScript can't handle that precision
var MAX_EXPIRY = Math.pow(2, 62);
aWindows.forEach(function(aWindow) {
if (!aWindow._hosts)
return;
for (var [host, isPinned] in Iterator(aWindow._hosts)) {
- var list = Services.cookies.getCookiesFromHost(host);
- while (list.hasMoreElements()) {
- var cookie = list.getNext().QueryInterface(Components.interfaces.nsICookie2);
- // aWindow._hosts will only have hosts with the right privacy rules,
- // so there is no need to do anything special with this call to
- // _checkPrivacyLevel.
- if (cookie.isSession && _this._checkPrivacyLevel(cookie.isSecure, isPinned)) {
- // use the cookie's host, path, and name as keys into a hash,
- // to make sure we serialize each cookie only once
-
- // lazily build up a 3-dimensional hash, with
- // host, path, and name as keys
- if (!jscookies[cookie.host])
- jscookies[cookie.host] = {};
- if (!jscookies[cookie.host][cookie.path])
- jscookies[cookie.host][cookie.path] = {};
-
- if (!jscookies[cookie.host][cookie.path][cookie.name]) {
- var jscookie = { "host": cookie.host, "value": cookie.value };
- // only add attributes with non-default values (saving a few bits)
- if (cookie.path) jscookie.path = cookie.path;
- if (cookie.name) jscookie.name = cookie.name;
- if (cookie.isSecure) jscookie.secure = true;
- if (cookie.isHttpOnly) jscookie.httponly = true;
- if (cookie.expiry < MAX_EXPIRY) jscookie.expiry = cookie.expiry;
-
- jscookies[cookie.host][cookie.path][cookie.name] = jscookie;
+ try {
+ var list = Services.cookies.getCookiesFromHost(host);
+ while (list.hasMoreElements()) {
+ var cookie = list.getNext().QueryInterface(Components.interfaces.nsICookie2);
+ // aWindow._hosts will only have hosts with the right privacy rules,
+ // so there is no need to do anything special with this call to
+ // _checkPrivacyLevel.
+ if (cookie.isSession && _this._checkPrivacyLevel(cookie.isSecure, isPinned)) {
+ // use the cookie's host, path, and name as keys into a hash,
+ // to make sure we serialize each cookie only once
+
+ // lazily build up a 3-dimensional hash, with
+ // host, path, and name as keys
+ if (!jscookies[cookie.host])
+ jscookies[cookie.host] = {};
+ if (!jscookies[cookie.host][cookie.path])
+ jscookies[cookie.host][cookie.path] = {};
+
+ if (!jscookies[cookie.host][cookie.path][cookie.name]) {
+ var jscookie = { "host": cookie.host, "value": cookie.value };
+ // only add attributes with non-default values (saving a few bits)
+ if (cookie.path) jscookie.path = cookie.path;
+ if (cookie.name) jscookie.name = cookie.name;
+ if (cookie.isSecure) jscookie.secure = true;
+ if (cookie.isHttpOnly) jscookie.httponly = true;
+ if (cookie.expiry < MAX_EXPIRY) jscookie.expiry = cookie.expiry;
+
+ jscookies[cookie.host][cookie.path][cookie.name] = jscookie;
+ }
+ aWindow.cookies.push(jscookies[cookie.host][cookie.path][cookie.name]);
}
- aWindow.cookies.push(jscookies[cookie.host][cookie.path][cookie.name]);
}
}
+ catch (ex) {
+ debug("getCookiesFromHost failed. Host: " + host);
+ }
}
});
// don't include empty cookie sections
for (i = 0; i < aWindows.length; i++)
if (aWindows[i].cookies.length == 0)
delete aWindows[i].cookies;
},