lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev Lotsa cookie changes


From: Klaus Weide
Subject: lynx-dev Lotsa cookie changes
Date: Tue, 15 Dec 1998 19:22:54 -0600 (CST)

Patch against lynx2.8.2dev.9 (for a change).  Please test!

I have only tested (briefly) equivalent changes for 2.8.1rel.2.

    Klaus


* FROM_FILE is not used any more dor a domain (although it is currently
  still defined.  Renamed COOKIE_FLAG_PERSISTENT to COOKIE_FLAG_FROM_FILE.
  Don't change a domain's "behaviour" (ACCEPT_ALWAYS, REJECT_ALWAYS, or
  QUERY_USER) just because there was a persistent cookie for it.  Users
  who want to always accept cookies from a domain without prompting should
  use COOKIE_ACCEPT_DOMAINS.
* FREE domain_entry objects when they are not used any more.  Other minor
  leak removed.
* Some (few) changes for draft-ietf-http-state-man-mec-10.txt.  Don't accept
  invalid port lists (this may need more tweaking).  Added some comments.
* Try to preserve cookies (within a domain) in the same order in which they
  were received, although this is probably not necessary after all.  There
  is no difference any more w.r.t. insertion into the list between cookies
  from the file and cookies from response headers.
* Use <= instead of < comparison when checking whether a cookie has expired.
* Don't write expired cookies, cookies with discard attribute, or cookies
  without expiration date to persistent file.
* Don't call HTConfirmCookie for cookies read from file.  This doesn't
  change the logic since previously HTConfirmCookie allowed all file cookies
  anyway.
* Don't delete the domain_list if it becomes empty.  Doing this could result
  in unnecessary multiple atexit()'s.
* Write the cookie file even if we now have no cookies, if we have previously
  read cookies from the file.  The file should be updated if all cookies that
  were in it are expired or superseded or deleted.
* When reading file cookies, set attributes in a way that (hopefully) makes
  more sense than just ignoring them.  See comments in LYLoadCookies.
  We are restricted a lot by the choice of a netscape-compatible cookie file
  format, some version 1 properties just cannot be stored in it AFAIK.
  Some more tweaking in LYLoadCookies.
* Setting a domains behaviour to accept "A)lways" didn't actually work, it
  had the same effect as "P)rompt".  Corrected this simple (probably
  cut-and-paste) error.
* Some changes in what is displayed on Cookie Jar page: FROM_FILE is a
  property of individual cookies, not of domains as previously.  Cookies
  from file (which haven't been updated) are shown as "(from a previous
  session)".  Show expiration time ("Max. Gobble Date") whenever we have
  one.  The state of the "discard" attribute is already displayed
  separately.

*** lynx2-8-2.orig/src/LYCookie.c       Tue Dec 15 09:14:58 1998
--- lynx2-8-2/src/LYCookie.c    Tue Dec 15 17:53:36 1998
***************
*** 16,22 ****
--- 16,35 ----
  **   
ftp://ds.internic.net/internet-drafts/draft-ietf-http-state-man-mec-03.txt
  **            - FM                                    1997-08-02
  **
+ **    Partially checked against:
+ **   http://www.ietf.org/internet-drafts/draft-ietf-http-state-man-mec-10.txt
+ **            - kw                                    1998-12-11
+ **
  **  TO DO: (roughly in order of decreasing priority)
+       * Persistent cookies are still experimental.  Presently cookies
+       lose many pieces of information that distinguish
+       version 1 from version 0 cookies.  There is no easy way around
+       that with the current cookie file format.  Ports are currently
+       not stored persistently at all which is clearly wrong.
+       * We currently don't do anything special for unverifiable
+       transactions to third-party hosts.
+       * We currently don't use effective host names or check for
+       Domain=.local.
        * Hex escaping isn't considered at all.  Any semi-colons, commas,
        or spaces actually in cookie names or values (i.e., not serving
        as punctuation for the overall Set-Cookie value) should be hex
***************
*** 92,98 ****
      int flags;           /* Various flags */
      time_t expires;/* The time when this cookie expires */
      BOOL quoted;   /* Was a value quoted in the Set-Cookie header? */
-     BOOL from_file; /* Was this cookie loaded from the file jar? - RP */
  };
  typedef struct _cookie cookie;
  
--- 105,110 ----
***************
*** 101,107 ****
  #define COOKIE_FLAG_EXPIRES_SET 4  /* If set, an expiry date was set */
  #define COOKIE_FLAG_DOMAIN_SET 8   /* If set, an non-default domain was set */
  #define COOKIE_FLAG_PATH_SET 16    /* If set, an non-default path was set */
! #define COOKIE_FLAG_PERSISTENT 32  /* If set, this cookie was persistent */
  
  struct _HTStream
  {
--- 113,119 ----
  #define COOKIE_FLAG_EXPIRES_SET 4  /* If set, an expiry date was set */
  #define COOKIE_FLAG_DOMAIN_SET 8   /* If set, an non-default domain was set */
  #define COOKIE_FLAG_PATH_SET 16    /* If set, an non-default path was set */
! #define COOKIE_FLAG_FROM_FILE 32  /* If set, this cookie was persistent */
  
  struct _HTStream
  {
***************
*** 177,182 ****
--- 189,195 ----
            FREE(de->domain);
            HTList_delete(de->cookie_list);
            de->cookie_list = NULL;
+             FREE(dl->object);
        }
        dl = dl->next;
      }
***************
*** 203,211 ****
  
      /*
       *        The following will pass a "dotted tail" match to "a.b.c.e"
!      *        as described in Section 2 of the -05 draft.
       */
!     if (*B == '.') {
        int diff = (strlen(A) - strlen(B));
        if (diff > 0) {
            if (!strcmp((A + diff), B))
--- 216,224 ----
  
      /*
       *        The following will pass a "dotted tail" match to "a.b.c.e"
!      *        as described in Section 2 of 
draft-ietf-http-state-man-mec-10.txt.
       */
!     if (*B == '.' && B[1] != '\0' && B[1] != '.' && *A != '.') {
        int diff = (strlen(A) - strlen(B));
        if (diff > 0) {
            if (!strcmp((A + diff), B))
***************
*** 385,391 ****
        de = (domain_entry *)calloc(1, sizeof(domain_entry));
        if (de == NULL)
            outofmem(__FILE__, "store_cookie");
! #ifdef EXP_PERSISTENT_COOKIES
        /*
         * Ok, this is a problem.  The first cookie for a domain
         * effectively sets the policy for that whole domain - for
--- 398,404 ----
        de = (domain_entry *)calloc(1, sizeof(domain_entry));
        if (de == NULL)
            outofmem(__FILE__, "store_cookie");
! #if 0 /* was: ifdef EXP_PERSISTENT_COOKIES */
        /*
         * Ok, this is a problem.  The first cookie for a domain
         * effectively sets the policy for that whole domain - for
***************
*** 396,402 ****
         * and the path in conjunction makes more sense?  - RP
         */
        if (persistent_cookies
!        && (co->flags & COOKIE_FLAG_PERSISTENT))
            de->bv = FROM_FILE;
        else
  #endif
--- 409,415 ----
         * and the path in conjunction makes more sense?  - RP
         */
        if (persistent_cookies
!          && (co->flags & COOKIE_FLAG_FROM_FILE))
            de->bv = FROM_FILE;
        else
  #endif
***************
*** 419,425 ****
         */
        if ((c2 != NULL) &&
            (c2->flags & COOKIE_FLAG_EXPIRES_SET) &&
!           c2->expires < now) {
            HTList_removeObject(cookie_list, c2);
            freeCookie(c2);
            c2 = NULL;
--- 432,438 ----
         */
        if ((c2 != NULL) &&
            (c2->flags & COOKIE_FLAG_EXPIRES_SET) &&
!           c2->expires <= now) {
            HTList_removeObject(cookie_list, c2);
            freeCookie(c2);
            c2 = NULL;
***************
*** 438,444 ****
            total_cookies--;
            Replacement = TRUE;
  
!       } else if ((c2) && (c2->pathlen) > (co->pathlen)) {
            pos++;
        }
        hl = next;
--- 451,473 ----
            total_cookies--;
            Replacement = TRUE;
  
!       } else if ((c2) && (c2->pathlen) >= (co->pathlen)) {
!           /*
!            *  This comparison determines the (tentative) position
!            *  of the new cookie in the list such that it comes
!            *  before existing cookies with a less specific path,
!            *  but after existing cookies of equal (or greater)
!            *  path length.  Thus it should normally preserve
!            *  the order of new cookies with the same path as
!            *  they are received, although this is not required.
!            *  From RFC 2109 4.3.4:
!   
!    If multiple cookies satisfy the criteria above, they are ordered in
!    the Cookie header such that those with more specific Path
!    attributes precede those with less specific.  Ordering with respect
!    to other attributes (e.g., Domain) is unspecified.
!            
!            */
            pos++;
        }
        hl = next;
***************
*** 447,453 ****
      /*
       *        Don't bother to add the cookie if it's already expired.
       */
!     if ((co->flags & COOKIE_FLAG_EXPIRES_SET) && co->expires < now) {
        freeCookie(co);
        co = NULL;
  
--- 476,482 ----
      /*
       *        Don't bother to add the cookie if it's already expired.
       */
!     if ((co->flags & COOKIE_FLAG_EXPIRES_SET) && co->expires <= now) {
        freeCookie(co);
        co = NULL;
  
***************
*** 487,512 ****
      /*
       *        Get confirmation if we need it, and add cookie
       *        if confirmed or 'allow' is set to always. - FM
       */
!     } else if (HTConfirmCookie(de, hostname, co->name, co->value)) {
! 
! #ifdef EXP_PERSISTENT_COOKIES
        /*
!        * If the cookie domain came from persistent cookie file,
!        * we want to add new cookies to the end of the cookie list
!        * to maintain their order for servers that need cookies in
!        * a particular order.  This is a hack.
!        */
!       if (persistent_cookies) {
!           if ((de->bv = FROM_FILE) != 0) {
!               HTList_appendObject(cookie_list, co);
!           } else {
!               HTList_insertObjectAt(cookie_list, co, pos);
!           }
!       }
! #else
        HTList_insertObjectAt(cookie_list, co, pos);
- #endif /* EXP_PERSISTENT_COOKIES */
        total_cookies++;
      } else {
        freeCookie(co);
--- 516,536 ----
      /*
       *        Get confirmation if we need it, and add cookie
       *        if confirmed or 'allow' is set to always. - FM
+      *
+      *  Cookies read from file are accepted without confirmation
+      *  prompting.  (Prompting may actually not be possible if
+      *  LYLoadCookies is called before curses is setup.)  Maybe
+      *  this should instead depend on LYSetCookies and/or
+      *  LYCookieAcceptDomains and/or LYCookieRejectDomains and/or
+      *  LYAcceptAllCookies and/or some other settings. -kw
       */
!     } else if ((persistent_cookies && (co->flags & COOKIE_FLAG_FROM_FILE))
!              || HTConfirmCookie(de, hostname, co->name, co->value)) {
        /*
!        * Insert the new cookie so that more specific paths (longer
!        * pathlen) come first in the list. - kw
!        */
        HTList_insertObjectAt(cookie_list, co, pos);
        total_cookies++;
      } else {
        freeCookie(co);
***************
*** 542,548 ****
                            (long)hl,
                            (co->name ? co->name : "(no name)"),
                            (co->value ? co->value : "(no value)"));
!           CTRACE(tfp, "%s %s %d %s %s %d%s\n",
                            hostname,
                            (co->domain ? co->domain : "(no domain)"),
                            host_matches(hostname, co->domain),
--- 566,572 ----
                            (long)hl,
                            (co->name ? co->name : "(no name)"),
                            (co->value ? co->value : "(no value)"));
!           CTRACE(tfp, "\t%s %s %d %s %s %d%s\n",
                            hostname,
                            (co->domain ? co->domain : "(no domain)"),
                            host_matches(hostname, co->domain),
***************
*** 555,561 ****
         *  Check if this cookie has expired, and if so, delete it.
         */
        if (((co) && (co->flags & COOKIE_FLAG_EXPIRES_SET)) &&
!           co->expires < now) {
            HTList_removeObject(sublist, co);
            freeCookie(co);
            co = NULL;
--- 579,585 ----
         *  Check if this cookie has expired, and if so, delete it.
         */
        if (((co) && (co->flags & COOKIE_FLAG_EXPIRES_SET)) &&
!           co->expires <= now) {
            HTList_removeObject(sublist, co);
            freeCookie(co);
            co = NULL;
***************
*** 708,713 ****
--- 732,738 ----
      int NumCookies = 0;
      BOOL MaxAgeAttrSet = FALSE;
      BOOL Quoted = FALSE;
+     BOOLEAN invalidport = FALSE;
  
      if (!(SetCookie && *SetCookie) &&
        !(SetCookie2 && *SetCookie2)) {
***************
*** 1052,1058 ****
                            *cp == ',' || *cp == ' ')) {
                        cp++;
                    }
!                   if (*cp == '\0') {
                        StrAllocCopy(cur_cookie->PortList, value);
                        length += strlen(cur_cookie->PortList);
                        known_attr = YES;
--- 1077,1086 ----
                            *cp == ',' || *cp == ' ')) {
                        cp++;
                    }
!                   if (*cp == '\0' && !port_matches(port, value)) {
!                       invalidport = TRUE;
!                       known_attr = YES;
!                   } else if (*cp == '\0') {
                        StrAllocCopy(cur_cookie->PortList, value);
                        length += strlen(cur_cookie->PortList);
                        known_attr = YES;
***************
*** 1112,1118 ****
                known_attr = YES;
                if ((cur_cookie != NULL && !MaxAgeAttrSet) &&
                     !(cur_cookie->flags & COOKIE_FLAG_EXPIRES_SET)) {
-                   known_attr = YES;
                    if (value) {
                        cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET;
                        cur_cookie->expires = LYmktime(value, FALSE);
--- 1140,1145 ----
***************
*** 1145,1151 ****
                 *  If we've started a cookie, and it's not too big,
                 *  save it in the CombinedCookies list. - FM
                 */
!               if (length <= max_cookies_buffer && cur_cookie != NULL) {
                    /*
                     *  Assume version 1 if not set to that or higher. - FM
                     */
--- 1172,1179 ----
                 *  If we've started a cookie, and it's not too big,
                 *  save it in the CombinedCookies list. - FM
                 */
!               if (length <= max_cookies_buffer && cur_cookie != NULL &&
!                   !invalidport) {
                    /*
                     *  Assume version 1 if not set to that or higher. - FM
                     */
***************
*** 1161,1167 ****
                                (cur_cookie->value ?
                                 cur_cookie->value : "[no value]"));
                    CTRACE(tfp,
!                          "                     due to excessive length!\n");
                    freeCookie(cur_cookie);
                    cur_cookie = NULL;
                }
--- 1189,1200 ----
                                (cur_cookie->value ?
                                 cur_cookie->value : "[no value]"));
                    CTRACE(tfp,
!                          invalidport ?
!                          "                     due to excessive length!\n"
!                        : "                     due to invalid port!\n");
!                   if (invalidport) {
!                       NumCookies --;
!                   }
                    freeCookie(cur_cookie);
                    cur_cookie = NULL;
                }
***************
*** 1169,1174 ****
--- 1202,1208 ----
                 *  Start a new cookie. - FM
                 */
                cur_cookie = newCookie();
+               invalidport = FALSE;
                length = 0;
                NumCookies++;
                MemAllocCopy(&(cur_cookie->name), attr_start, attr_end);
***************
*** 1193,1204 ****
       */
      if (NumCookies <= max_cookies_domain
       && length <= max_cookies_buffer
!      && cur_cookie != NULL) {
        if (cur_cookie->version < 1) {
            cur_cookie->version = 1;
        }
        HTList_appendObject(CombinedCookies, cur_cookie);
!     } else if (cur_cookie != NULL) {
        CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n",
                    (cur_cookie->name ? cur_cookie->name : "[no name]"),
                    (cur_cookie->value ? cur_cookie->value : "[no value]"));
--- 1227,1238 ----
       */
      if (NumCookies <= max_cookies_domain
       && length <= max_cookies_buffer
!      && cur_cookie != NULL && !invalidport) {
        if (cur_cookie->version < 1) {
            cur_cookie->version = 1;
        }
        HTList_appendObject(CombinedCookies, cur_cookie);
!     } else if (cur_cookie != NULL && !invalidport) {
        CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n",
                    (cur_cookie->name ? cur_cookie->name : "[no name]"),
                    (cur_cookie->value ? cur_cookie->value : "[no value]"));
***************
*** 1211,1216 ****
--- 1245,1258 ----
                    (NumCookies > max_cookies_domain ? "number!\n" : "!\n"));
        freeCookie(cur_cookie);
        cur_cookie = NULL;
+     } else if (cur_cookie != NULL) {                  /* invalidport */
+       CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n",
+                   (cur_cookie->name ? cur_cookie->name : "[no name]"),
+                   (cur_cookie->value ? cur_cookie->value : "[no value]"));
+       CTRACE(tfp, "                     due to invalid port!\n");
+       NumCookies --;
+       freeCookie(cur_cookie);
+       cur_cookie = NULL;
      }
  
      /*
***************
*** 1536,1542 ****
                            *cp == ',' || *cp == ' ')) {
                        cp++;
                    }
!                   if (*cp == '\0') {
                        StrAllocCopy(cur_cookie->PortList, value);
                        length += strlen(cur_cookie->PortList);
                        known_attr = YES;
--- 1578,1584 ----
                            *cp == ',' || *cp == ' ')) {
                        cp++;
                    }
!                   if (*cp == '\0' && port_matches(port, value)) {
                        StrAllocCopy(cur_cookie->PortList, value);
                        length += strlen(cur_cookie->PortList);
                        known_attr = YES;
***************
*** 1559,1565 ****
                    /*
                     *  Don't process a repeat version. - FM
                     */
!                   cur_cookie->version < 0) {
                    int temp = strtol(value, NULL, 10);
                    if (errno != -ERANGE) {
                        cur_cookie->version = temp;
--- 1601,1607 ----
                    /*
                     *  Don't process a repeat version. - FM
                     */
!                   cur_cookie->version < 1) {
                    int temp = strtol(value, NULL, 10);
                    if (errno != -ERANGE) {
                        cur_cookie->version = temp;
***************
*** 1839,1845 ****
                HTList_delete(de->cookie_list);
                de->cookie_list = NULL;
                HTList_removeObject(domain_list, de);
!               de = NULL;
            }
        }
        hl = next;
--- 1881,1887 ----
                HTList_delete(de->cookie_list);
                de->cookie_list = NULL;
                HTList_removeObject(domain_list, de);
!               FREE(de);
            }
        }
        hl = next;
***************
*** 1847,1867 ****
      if (header)
        return(header);
  
-     /*
-      *        If we didn't set a header, perhaps all the cookies have
-      *        expired and we deleted the last of them above, so check
-      *        if we should delete and NULL the domain_list. - FM
-      */
-     if (domain_list) {
-       if (HTList_isEmpty(domain_list)) {
-           HTList_delete(domain_list);
-           domain_list = NULL;
-       }
-     }
      return(NULL);
  }
  
  #ifdef EXP_PERSISTENT_COOKIES
  /* rjp - experiment cookie loading */
  PUBLIC void LYLoadCookies ARGS1 (
        char *,         cookie_file)
--- 1889,1900 ----
      if (header)
        return(header);
  
      return(NULL);
  }
  
  #ifdef EXP_PERSISTENT_COOKIES
+ PRIVATE int number_of_file_cookies = 0;
+ 
  /* rjp - experiment cookie loading */
  PUBLIC void LYLoadCookies ARGS1 (
        char *,         cookie_file)
***************
*** 1891,1896 ****
--- 1924,1930 ----
  
      CTRACE(tfp, "LYLoadCookies: reading cookies from %s\n", cookie_file);
  
+     number_of_file_cookies = 0;
      while (!feof(cookie_handle)) {
        cookie *moo;
        unsigned i = 0;
***************
*** 1901,1909 ****
--- 1935,1947 ----
        j = fgets(buf, sizeof(buf)-1, cookie_handle);
  
        if((j == NULL) || (buf[0] == '\0' || buf[0] == '\n' || buf[0] == '#')) {
+           if (j == NULL && ferror(cookie_handle))
+               break;
            continue;
        }
  
+       number_of_file_cookies ++;
+       
        /*
         * Strip out the newline that fgets() puts at the end of a
         * cookie.
***************
*** 1957,1969 ****
        StrAllocCopy(moo->name, name);
        StrAllocCopy(moo->value, value);
        moo->pathlen = strlen(moo->path);
!       moo->flags |= COOKIE_FLAG_PERSISTENT;
        moo->expires = expires;
        /*
         * I don't like using this to store the cookies because it's
         * designed to store cookies that have been received from an
         * HTTP request, not from a persistent cookie jar.  Hence the
!        * mucking about with the COOKIE_FLAG_PERSISTENT above. - RP
         */
        store_cookie(moo, domain, path);
      }
--- 1995,2045 ----
        StrAllocCopy(moo->name, name);
        StrAllocCopy(moo->value, value);
        moo->pathlen = strlen(moo->path);
!       /*
!        *  Justification for following flags:
!        *  COOKIE_FLAG_FROM_FILE    So we know were it comes from.
!        *  COOKIE_FLAG_EXPIRES_SET  It must have had an explicit
!        *                           expiration originally, otherwise
!        *                           it wouldn ot be in the file.
!        *  COOKIE_FLAG_DOMAN_SET,   We don't know whether these were
!        *   COOKIE_FLAG_PATH_SET    explicit or implicit, but this
!        *                           only matters for sending version 1
!        *                           cookies; the cookies read from the
!        *                           file are currently treated all like
!        *                           version 0 (we don't set moo->version)
!        *                           so $Domain= and $Path= will normally
!        *                           not be sent to the server.  But if
!        *                           these cookies somehow get mixed with
!        *                           new version 1 cookies we may end up
!        *                           sending version 1 to the server, and
!        *                           in that case we should send $Domain
!        *                           and $Path.  The state-man-mec drafts
!        *                           and RFC 2109 say that $Domain and
!        *                           $Path SHOULD be omitted if they were
!        *                           not given explicitly, but not that
!        *                           they MUST be omitted.
!        *                           See 8.2 Cookie Spoofing in draft -10
!        *                           for a good reason to send them.
!        *                           However, an explicit domain should be
!        *                           now prefixed with a dot (unless it is
!        *                           for a single host), so we check for
!        *                           that.
!        *  COOKIE_FLAG_SECURE       Should have "FALSE" for normal,
!        *                           otherwise set it.
!        */
!       moo->flags |= COOKIE_FLAG_FROM_FILE | COOKIE_FLAG_EXPIRES_SET |
!                       COOKIE_FLAG_PATH_SET;
!       if (domain[0] == '.')
!           moo->flags |= COOKIE_FLAG_DOMAIN_SET;
!       if (secure[0] != 'F')
!           moo->flags |= COOKIE_FLAG_SECURE;
!       /* @@@ Should we set port to 443 if secure is set? @@@ */
        moo->expires = expires;
        /*
         * I don't like using this to store the cookies because it's
         * designed to store cookies that have been received from an
         * HTTP request, not from a persistent cookie jar.  Hence the
!        * mucking about with the COOKIE_FLAG_FROM_FILE above. - RP
         */
        store_cookie(moo, domain, path);
      }
***************
*** 1986,1996 ****
      /*
       *        Check whether we have something to do. - FM
       */
!     if (HTList_isEmpty(domain_list)) {
!       /* No cookies, so don't bother updating the file */
        return;
      }
  
      cookie_handle = LYNewTxtFile (cookie_file);
      for (dl = domain_list; dl != NULL; dl = dl->next) {
        de = dl->object;
--- 2062,2077 ----
      /*
       *        Check whether we have something to do. - FM
       */
!     if (HTList_isEmpty(domain_list) &&
!       number_of_file_cookies == 0) {
!       /* No cookies now, and haven't read any,
!        * so don't bother updating the file.
!        */
        return;
      }
  
+     CTRACE(tfp, "LYStoreCookies: save cookies to %s on exit\n", cookie_file);
+ 
      cookie_handle = LYNewTxtFile (cookie_file);
      for (dl = domain_list; dl != NULL; dl = dl->next) {
        de = dl->object;
***************
*** 2011,2017 ****
        case (QUERY_USER):
            HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
            break;
!       case (FROM_FILE):
            HTSprintf0(&buf, gettext("(From Cookie Jar)"));
            break;
        }
--- 2092,2098 ----
        case (QUERY_USER):
            HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
            break;
!       case (FROM_FILE):       /* not used any more - kw */
            HTSprintf0(&buf, gettext("(From Cookie Jar)"));
            break;
        }
***************
*** 2028,2039 ****
            if ((co = (cookie *)cl->object) == NULL)
                continue;
  
!           CTRACE(tfp, "LYStoreCookies: %ld cf %ld\n", (long) now, (long) 
co->expires);
            fprintf(cookie_handle, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\n",
                de->domain,
                "FALSE", co->path,
                co->flags & COOKIE_FLAG_SECURE ? "TRUE" : "FALSE",
                (long) co->expires, co->name, co->value);
        }
      }
      fclose(cookie_handle);
--- 2109,2134 ----
            if ((co = (cookie *)cl->object) == NULL)
                continue;
  
!           CTRACE(tfp, "LYStoreCookies: %ld cf %ld ", (long) now, (long) 
co->expires);
! 
!           if ((co->flags & COOKIE_FLAG_DISCARD)) {
!               CTRACE(tfp, "not stored - DISCARD\n");
!               continue;
!           } else if (!(co->flags & COOKIE_FLAG_EXPIRES_SET)) {
!               CTRACE(tfp, "not stored - no expiration time\n");
!               continue;
!           } else if (co->expires <= now) {
!               CTRACE(tfp, "not stored - EXPIRED\n");
!               continue;
!           }
! 
            fprintf(cookie_handle, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\n",
                de->domain,
                "FALSE", co->path,
                co->flags & COOKIE_FLAG_SECURE ? "TRUE" : "FALSE",
                (long) co->expires, co->name, co->value);
+ 
+           CTRACE(tfp, "STORED\n");
        }
      }
      fclose(cookie_handle);
***************
*** 2081,2087 ****
      /*
       *        Check whether we have something to do. - FM
       */
!     if (domain_list == NULL) {
        HTProgress(COOKIE_JAR_IS_EMPTY);
        sleep(MessageSecs);
        return(HT_NO_DATA);
--- 2176,2182 ----
      /*
       *        Check whether we have something to do. - FM
       */
!     if (HTList_isEmpty(domain_list)) {
        HTProgress(COOKIE_JAR_IS_EMPTY);
        sleep(MessageSecs);
        return(HT_NO_DATA);
***************
*** 2120,2125 ****
--- 2215,2221 ----
                 */
                continue;
            if (!strcmp(domain, de->domain)) {
+               FREE(domain);
                /*
                 *  We found the domain.  Check
                 *  whether a lynxID is present. - FM
***************
*** 2159,2165 ****
                                HTList_delete(de->cookie_list);
                                de->cookie_list = NULL;
                                HTList_removeObject(domain_list, de);
!                               de = NULL;
                                HTProgress(DOMAIN_EATEN);
                            } else {
                                HTProgress(COOKIE_EATEN);
--- 2255,2261 ----
                                HTList_delete(de->cookie_list);
                                de->cookie_list = NULL;
                                HTList_removeObject(domain_list, de);
!                               FREE(de);
                                HTProgress(DOMAIN_EATEN);
                            } else {
                                HTProgress(COOKIE_EATEN);
***************
*** 2194,2200 ****
                                 *  Set to accept all cookies
                                 *  from this domain. - FM
                                 */
!                               de->bv = QUERY_USER;
                                HTUserMsg2(ALWAYS_ALLOWING_COOKIES,
                                              de->domain);
                                return(HT_NO_DATA);
--- 2290,2296 ----
                                 *  Set to accept all cookies
                                 *  from this domain. - FM
                                 */
!                               de->bv = ACCEPT_ALWAYS;
                                HTUserMsg2(ALWAYS_ALLOWING_COOKIES,
                                              de->domain);
                                return(HT_NO_DATA);
***************
*** 2218,2224 ****
                                    HTList_delete(de->cookie_list);
                                    de->cookie_list = NULL;
                                    HTList_removeObject(domain_list, de);
!                                   de = NULL;
                                    HTProgress(DOMAIN_EATEN);
                                    sleep(MessageSecs);
                                    break;
--- 2314,2320 ----
                                    HTList_delete(de->cookie_list);
                                    de->cookie_list = NULL;
                                    HTList_removeObject(domain_list, de);
!                                   FREE(de);
                                    HTProgress(DOMAIN_EATEN);
                                    sleep(MessageSecs);
                                    break;
***************
*** 2258,2264 ****
                                    HTList_delete(de->cookie_list);
                                    de->cookie_list = NULL;
                                    HTList_removeObject(domain_list, de);
!                                   de = NULL;
                                    HTProgress(DOMAIN_EATEN);
                                    sleep(MessageSecs);
                                }
--- 2354,2360 ----
                                    HTList_delete(de->cookie_list);
                                    de->cookie_list = NULL;
                                    HTList_removeObject(domain_list, de);
!                                   FREE(de);
                                    HTProgress(DOMAIN_EATEN);
                                    sleep(MessageSecs);
                                }
***************
*** 2298,2311 ****
        }
        if (HTList_isEmpty(domain_list)) {
            /*
!            *  There are no more domains left,
!            *  so delete the domain_list. - FM
             */
-           HTList_delete(domain_list);
-           domain_list = NULL;
            HTProgress(ALL_COOKIES_EATEN);
            sleep(MessageSecs);
        }
        return(HT_NO_DATA);
      }
  
--- 2394,2407 ----
        }
        if (HTList_isEmpty(domain_list)) {
            /*
!            *  There are no more domains left.
!            *  Don't delete the domain_list, otherwise
!            *  atexit may be called multiple times. - kw
             */
            HTProgress(ALL_COOKIES_EATEN);
            sleep(MessageSecs);
        }
+       FREE(domain);
        return(HT_NO_DATA);
      }
  
***************
*** 2371,2379 ****
            case (QUERY_USER):
                HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
                break;
!           case (FROM_FILE):
                HTSprintf0(&buf, COOKIES_READ_FROM_FILE);
                break;
        }
        (*target->isa->put_block)(target, buf, strlen(buf));
        HTSprintf0(&buf, "\n");
--- 2467,2477 ----
            case (QUERY_USER):
                HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
                break;
! #if 0
!           case (FROM_FILE):   /* not used any more - kw */
                HTSprintf0(&buf, COOKIES_READ_FROM_FILE);
                break;
+ #endif
        }
        (*target->isa->put_block)(target, buf, strlen(buf));
        HTSprintf0(&buf, "\n");
***************
*** 2410,2415 ****
--- 2508,2518 ----
            FREE(value);
            (*target->isa->put_block)(target, buf, strlen(buf));
  
+           if (co->flags & COOKIE_FLAG_FROM_FILE) {
+               HTSprintf0(&buf, "%s\n", gettext("(from a previous session)"));
+               (*target->isa->put_block)(target, buf, strlen(buf));
+           }
+               
            /*
             *  Show the path, port, secure and discard setting. - FM
             */
***************
*** 2467,2478 ****
             */
            HTSprintf0(&buf, "<DD><EM>%s</EM> %s%s",
                         gettext("Maximum Gobble Date:"),
!                        ((co->expires > 0 &&
!                          !(co->flags & COOKIE_FLAG_DISCARD))
                                            ?
                        ctime(&co->expires) : END_OF_SESSION),
!                        ((co->expires > 0 &&
!                          !(co->flags & COOKIE_FLAG_DISCARD))
                                            ?
                                         "" : "\n"));
            (*target->isa->put_block)(target, buf, strlen(buf));
--- 2570,2579 ----
             */
            HTSprintf0(&buf, "<DD><EM>%s</EM> %s%s",
                         gettext("Maximum Gobble Date:"),
!                        ((co->flags & COOKIE_FLAG_EXPIRES_SET)
                                            ?
                        ctime(&co->expires) : END_OF_SESSION),
!                        ((co->flags & COOKIE_FLAG_EXPIRES_SET)
                                            ?
                                         "" : "\n"));
            (*target->isa->put_block)(target, buf, strlen(buf));

reply via email to

[Prev in Thread] Current Thread [Next in Thread]