From bf4bad597eaae7e7cdff942985e3e48ff792b293 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Mon, 14 Aug 2000 23:00:54 +0000 Subject: [PATCH] 48884, r=morse. fixing cookie list ordering problem and cookie insertion problem. git-svn-id: svn://10.0.0.236/trunk@76314 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/cookie/nsCookie.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/mozilla/extensions/cookie/nsCookie.cpp b/mozilla/extensions/cookie/nsCookie.cpp index d6d2b84d31c..ba5a778bb22 100644 --- a/mozilla/extensions/cookie/nsCookie.cpp +++ b/mozilla/extensions/cookie/nsCookie.cpp @@ -632,12 +632,14 @@ cookie_GetLifetimeTime() { return get_current_time() + cookie_lifetimeLimit; } +#if 0 PRIVATE PRBool cookie_GetLifetimeAsk(time_t expireTime) { // return true if we should ask about this cookie return (cookie_GetLifetimePref() == COOKIE_Ask) && (cookie_GetLifetimeTime() < expireTime); } +#endif PRIVATE time_t cookie_TrimLifetime(time_t expires) { @@ -1015,7 +1017,6 @@ PUBLIC char * COOKIE_GetCookie(char * address) { char *name=0; cookie_CookieStruct * cookie_s; - PRBool first=PR_TRUE; PRBool xxx = PR_FALSE; time_t cur_time = get_current_time(); @@ -1077,18 +1078,13 @@ COOKIE_GetCookie(char * address) { cookie_cookieList->RemoveElementAt(i); deleteCookie((void*)cookie_s, nsnull); cookie_cookiesChanged = PR_TRUE; - - /* start the list parsing over :( we must also start the string over */ - PR_FREEIF(rv); - rv = NULL; - first = PR_TRUE; /* reset first */ continue; } - if(first) { - first = PR_FALSE; - } else { - StrAllocCat(rv, "; "); - } + + /* if we've already added a cookie to the return list, append a "; " so + * subsequent cookies are delimited in the final list. */ + if (rv) StrAllocCat(rv, "; "); + if(cookie_s->name && *cookie_s->name != '\0') { cookie_s->lastAccessed = cur_time; StrAllocCopy(name, cookie_s->name); @@ -1706,7 +1702,7 @@ cookie_SetCookieString(char * curURL, nsIPrompt *aPrompter, char * setCookieHead i--; tmp_cookie_ptr = NS_STATIC_CAST(cookie_CookieStruct*, cookie_cookieList->ElementAt(i)); NS_ASSERTION(tmp_cookie_ptr, "corrupt cookie list"); - if(new_len > PL_strlen(tmp_cookie_ptr->path)) { + if(new_len <= PL_strlen(tmp_cookie_ptr->path)) { cookie_cookieList->InsertElementAt(prev_cookie, i); bCookieAdded = PR_TRUE; break; @@ -2159,7 +2155,7 @@ cookie_Load() { i--; tmp_cookie_ptr = NS_STATIC_CAST(cookie_CookieStruct*, cookie_cookieList->ElementAt(i)); NS_ASSERTION(tmp_cookie_ptr, "corrupt cookie list"); - if (new_len > PL_strlen(tmp_cookie_ptr->path)) { + if (new_len <= PL_strlen(tmp_cookie_ptr->path)) { cookie_cookieList->InsertElementAt(new_cookie, i); added_to_list = PR_TRUE; break;