From 3a8eef8a25dd7e27321693d0556ccd12003fbf9f Mon Sep 17 00:00:00 2001 From: morse Date: Sun, 7 Jun 1998 16:01:49 +0000 Subject: [PATCH] cookie management changes --- network/protocol/http/mkaccess.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/network/protocol/http/mkaccess.c b/network/protocol/http/mkaccess.c index e90cea575b3..b1720c8ee50 100644 --- a/network/protocol/http/mkaccess.c +++ b/network/protocol/http/mkaccess.c @@ -2031,6 +2031,7 @@ net_IntSetCookieString(MWContext * context, #if defined(CookieManagement) { + Bool old_cookie_remember_checked = cookie_remember_checked; XP_Bool userHasAccepted = FE_CheckConfirm (context, new_string, @@ -2038,7 +2039,6 @@ net_IntSetCookieString(MWContext * context, &cookie_remember_checked); PR_FREEIF(new_string); PR_FREEIF(remember_string); - if (cookie_remember_checked) { net_lock_cookie_permission_list(); net_AddCookiePermission @@ -2046,6 +2046,12 @@ net_IntSetCookieString(MWContext * context, net_unlock_cookie_permission_list(); } + if (old_cookie_remember_checked != cookie_remember_checked) { + cookie_permissions_changed = TRUE; + net_SaveCookiePermissions(NULL); + } + + if (!userHasAccepted) { return; } @@ -2387,6 +2393,15 @@ net_SaveCookiePermissions(char * filename) } } + /* save current state of cookie nag-box's checkmark */ + XP_FileWrite("@@@@", -1, fp); + XP_FileWrite("\t", 1, fp); + if (cookie_remember_checked) { + XP_FileWrite("TRUE", -1, fp); + } else { + XP_FileWrite("FALSE", -1, fp); + } + cookie_permissions_changed = FALSE; XP_FileClose(fp); net_unlock_cookie_permission_list(); @@ -2406,6 +2421,7 @@ net_ReadCookiePermissions(char * filename) XP_File fp; char buffer[PERMISSION_LINE_BUFFER_SIZE]; char *host, *permission; + Bool permission_value; if(!(fp = XP_FileOpen(filename, xpHTTPCookiePermission, XP_FILE_READ))) return(-1); @@ -2420,6 +2436,7 @@ net_ReadCookiePermissions(char * filename) if (*buffer == '#' || *buffer == CR || *buffer == LF || *buffer == 0) { continue; } + host = buffer; if( !(permission = PL_strchr(host, '\t')) ) { @@ -2431,10 +2448,15 @@ net_ReadCookiePermissions(char * filename) } XP_StripLine(permission); /* remove '\n' from end of permission */ - if(!PL_strcmp(permission, "TRUE")) { - net_AddCookiePermission(host, TRUE, FALSE); + /* + * a host value of "@@@@" is a special code designating the + * state of the cookie nag-box's checkmark + */ + permission_value = (!PL_strcmp(permission, "TRUE")); + if (!PL_strcmp(host, "@@@@")) { + cookie_remember_checked = permission_value; } else { - net_AddCookiePermission(host, FALSE, FALSE); + net_AddCookiePermission(host, permission_value, FALSE); } }