fixes bug 177698, Cookie is not stored if its VALUE contains "max-age",

patch=dwitte@stanford.edu r/sr=alecf,darin
This commit is contained in:
darin%netscape.com 2003-02-23 00:04:03 +00:00
Родитель 95dfc6ea7a
Коммит 44f475da93
3 изменённых файлов: 588 добавлений и 684 удалений

Просмотреть файл

@ -46,6 +46,7 @@
#include "nsIGenericFactory.h"
#include "nsXPIDLString.h"
#include "nsIScriptGlobalObject.h"
#include "nsReadableUtils.h"
////////////////////////////////////////////////////////////////////////////////
@ -77,8 +78,8 @@ class nsCookieEnumerator : public nsISimpleEnumerator
nsCookieStatus status;
nsCookiePolicy policy;
nsresult rv = COOKIE_Enumerate
(mCookieCount++, name, value, &isDomain, host, path, &isSecure, &expires,
&status, &policy);
(mCookieCount++, name, value, isDomain, host, path, isSecure, expires,
status, policy);
if (NS_SUCCEEDED(rv)) {
nsICookie *cookie =
new nsCookie(name, value, isDomain, host, path, isSecure, expires,
@ -146,24 +147,13 @@ NS_IMETHODIMP nsCookieManager::Add(const nsACString &aDomain,
PRBool aSecure,
PRInt32 aExpires)
{
// nasty COOKIE method requires caller to hand off ownership of strings.
// nice COOKIE method doesn't require caller to hand off ownership of strings.
/* nulls aren't allowed (cookie code is full of checks as if they were
but see COOKIE_Write) */
char *domainCopy = PL_strdup(PromiseFlatCString(aDomain).get()),
*pathCopy = PL_strdup(PromiseFlatCString(aPath).get()),
*nameCopy = PL_strdup(PromiseFlatCString(aName).get()),
*valueCopy = PL_strdup(PromiseFlatCString(aValue).get());
if (domainCopy && pathCopy && nameCopy && valueCopy)
return ::COOKIE_AddCookie(domainCopy, pathCopy, nameCopy, valueCopy,
aSecure, PR_TRUE, aExpires,
nsICookie::STATUS_UNKNOWN, nsICookie::POLICY_UNKNOWN);
if (domainCopy) PL_strfree(domainCopy);
if (pathCopy) PL_strfree(pathCopy);
if (nameCopy) PL_strfree(nameCopy);
if (valueCopy) PL_strfree(valueCopy);
return NS_ERROR_OUT_OF_MEMORY;
return ::COOKIE_AddCookie(aDomain, aPath, aName, aValue,
aSecure, PR_TRUE, aExpires,
nsICookie::STATUS_UNKNOWN, nsICookie::POLICY_UNKNOWN);
}
NS_IMETHODIMP nsCookieManager::Remove
@ -171,8 +161,6 @@ NS_IMETHODIMP nsCookieManager::Remove
// (const nsAUTF8String& host, const nsACString& name, const nsAUTF8String& path, PRBool blocked) {
// using nsACString above instead of nsAUTF8String because the latter doesn't exist yet
::COOKIE_Remove(PromiseFlatCString(host).get(),
PromiseFlatCString(name).get(),
PromiseFlatCString(path).get(), blocked);
::COOKIE_Remove(host, name, path, blocked);
return NS_OK;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -66,28 +66,28 @@ extern void COOKIE_DeletePersistentUserData(void);
extern PRInt32 COOKIE_Count();
extern nsresult COOKIE_Enumerate
(PRInt32 count,
nsACString & name,
nsACString & value,
PRBool * isDomain,
nsACString & host,
nsACString & path,
PRBool * isSecure,
PRUint64 * expires,
nsCookieStatus * status,
nsCookiePolicy * policy);
nsACString &name,
nsACString &value,
PRBool &isDomain,
nsACString &host,
nsACString &path,
PRBool &isSecure,
PRUint64 &expires,
nsCookieStatus &status,
nsCookiePolicy &policy);
extern void COOKIE_Remove
(const char* host, const char* name, const char* path, const PRBool blocked);
extern nsresult COOKIE_AddCookie(char *aDomain, char *aPath,
char *aName, char *aValue,
(const nsACString &host, const nsACString &name, const nsACString &path, const PRBool blocked);
extern nsresult COOKIE_AddCookie(const nsACString &aDomain, const nsACString &aPath,
const nsACString &aName, const nsACString &aValue,
PRBool aSecure, PRBool aIsDomain,
time_t aExpires,
nsCookieStatus aStatus, nsCookiePolicy aPolicy);
typedef struct _cookie_CookieStruct {
char * path;
char * host;
char * name;
char * cookie;
nsCString path;
nsCString host;
nsCString name;
nsCString cookie;
time_t expires;
time_t lastAccessed;
PRBool isSecure;