зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434252 - nsICookieService may throw an error in certain circumstances, so let's make SessionCookies::restore infallible. r=dao
Please see bug 1462402 for more details and the root cause. SessionCookies.jsm uses nsICookieService::CookieExists and nsICookieService::Add to restore session-cookies. These currently throw for hostnames that contain a leading '.' and maybe other cases, so we need to wrap the calls in a try..catch block to prevent breakage, leading to an unrestored session. MozReview-Commit-ID: 9gZ7K6lwcQF --HG-- extra : rebase_source : 0c1bff428225a78a30c83187c455277372efe7e5
This commit is contained in:
Родитель
ad79b6e365
Коммит
ca6f45143e
|
@ -57,10 +57,20 @@ var SessionCookiesInternal = {
|
|||
};
|
||||
|
||||
let originAttributes = cookie.originAttributes || {};
|
||||
if (!Services.cookies.cookieExists(cookieObj, originAttributes)) {
|
||||
Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
|
||||
cookie.value, !!cookie.secure, !!cookie.httponly,
|
||||
/* isSession = */ true, expiry, originAttributes);
|
||||
let exists = false;
|
||||
try {
|
||||
exists = Services.cookies.cookieExists(cookieObj, originAttributes);
|
||||
} catch (ex) {
|
||||
Cu.reportError(`nsCookieService::CookieExists failed with error '${ex}' for '${JSON.stringify(cookie)}'.`);
|
||||
}
|
||||
if (!exists) {
|
||||
try {
|
||||
Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
|
||||
cookie.value, !!cookie.secure, !!cookie.httponly,
|
||||
/* isSession = */ true, expiry, originAttributes);
|
||||
} catch (ex) {
|
||||
Cu.reportError(`nsCookieService::Add failed with error '${ex}' for cookie ${JSON.stringify(cookie)}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче