зеркало из https://github.com/mozilla/pjs.git
Fixed bugs in cookieSyncCore.itemExists and cookieStore.addCommand. The problem in addCommand was just a missing argument, but in itemExists I had to change the implementation to use cookieManager.enumerator rather than cookieManager.findMatchingCookie -- the latter function apparently does not exist in the nsICookieManager2 interface despite what MDC says about it.
This commit is contained in:
Родитель
ecd1ab657d
Коммит
dc5e6d89c9
|
@ -787,6 +787,7 @@ CookieStore.prototype = {
|
|||
command.data.name,
|
||||
command.data.value,
|
||||
command.data.isSecure,
|
||||
command.data.isHttpOnly,
|
||||
command.data.isSession,
|
||||
command.data.expiry );
|
||||
},
|
||||
|
@ -822,8 +823,8 @@ CookieStore.prototype = {
|
|||
// that the cookie was set -- only the expiry. TODO: Figure out
|
||||
// the best way to deal with this.
|
||||
this._log.info("CookieStore got editCommand: " + command );
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
wrap: function CookieStore_wrap() {
|
||||
// Return contents of this store, as JSON.
|
||||
|
|
|
@ -449,35 +449,45 @@ CookieSyncCore.prototype = {
|
|||
|
||||
|
||||
_itemExists: function CSC__itemExists(GUID) {
|
||||
// true if a cookie with the given GUID exists.
|
||||
// The GUID that we are passed should correspond to the keys
|
||||
// that we define in the JSON returned by CookieStore.wrap()
|
||||
// That is, it will be a string of the form
|
||||
// "host:path:name".
|
||||
// true if a cookie with the given GUID exists.
|
||||
// The GUID that we are passed should correspond to the keys
|
||||
// that we define in the JSON returned by CookieStore.wrap()
|
||||
// That is, it will be a string of the form
|
||||
// "host:path:name".
|
||||
|
||||
// TODO verify that colons can't normally appear in any of
|
||||
// the fields -- if they did it then we can't rely on .split(":")
|
||||
// to parse correctly.
|
||||
|
||||
let cookieArray = GUID.split( ":" );
|
||||
let cookieHost = cookieArray[0];
|
||||
let cookiePath = cookieArray[1];
|
||||
let cookieName = cookieArray[2];
|
||||
|
||||
// TODO verify that colons can't normally appear in any of
|
||||
// the fields -- if they did it then we can't rely on .split(":")
|
||||
// to parse correctly.
|
||||
|
||||
let unused = 0; // for outparam from findMatchingCookie
|
||||
let cookieArray = GUID.split( ":" );
|
||||
// create a generic object to represent the cookie -- just has
|
||||
// to implement nsICookie2 interface.
|
||||
cookie = Object();
|
||||
cookie.host = cookieArray[0];
|
||||
cookie.path = cookieArray[1];
|
||||
cookie.name = cookieArray[2];
|
||||
return this._cookieManager.findMatchingCookie( cookie, unused );
|
||||
// alternate implementation would be to instantiate a cookie from
|
||||
// cookieHost, cookiePath, and cookieName,
|
||||
// then call cookieManager.cookieExists().
|
||||
let enumerator = this._cookieManager.enumerator;
|
||||
while (enumerator.hasMoreElements())
|
||||
{
|
||||
let aCookie = enumerator.getNext();
|
||||
if (aCookie.host == cookieHost &&
|
||||
aCookie.path == cookiePath &&
|
||||
aCookie.name == cookieName ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_commandLike: function CSC_commandLike(a, b) {
|
||||
// Method required to be overridden.
|
||||
// a and b each have a .data and a .GUID
|
||||
// If this function returns true, an editCommand will be
|
||||
// generated to try to resolve the thing.
|
||||
// but are a and b objects of the type in the Store or
|
||||
// are they "commands"??
|
||||
return false;
|
||||
// Method required to be overridden.
|
||||
// a and b each have a .data and a .GUID
|
||||
// If this function returns true, an editCommand will be
|
||||
// generated to try to resolve the thing.
|
||||
// but are a and b objects of the type in the Store or
|
||||
// are they "commands"??
|
||||
return false;
|
||||
}
|
||||
};
|
||||
CookieSyncCore.prototype.__proto__ = new SyncCore();
|
||||
|
|
Загрузка…
Ссылка в новой задаче