]> sjero.net Git - wget/commitdiff
[svn] Fix loading of cookies.
authorhniksic <devnull@localhost>
Wed, 25 Apr 2001 02:29:54 +0000 (19:29 -0700)
committerhniksic <devnull@localhost>
Wed, 25 Apr 2001 02:29:54 +0000 (19:29 -0700)
Published in <sxslmopyao6.fsf@florida.arsdigita.de>.

src/ChangeLog
src/cookies.c
src/http.c

index 08970a6959bb29b97171b13030e24d567a160382..a6bb7086b171072ce533208c854fbb22492c60d0 100644 (file)
@@ -1,3 +1,10 @@
+2001-04-25  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * http.c (http_loop): Would load cookies every time.
+
+       * cookies.c (load_cookies): Handle cookies whose values contain
+       embedded spaces.
+
 2001-04-25  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * utils.c: Define each DIGITS_* in one line.
index f915d820fbc4c992c8b9877579aedc91f670fc89..4c8e3a7b78d17979ffd246d378464bd7f7fdfbe5 100644 (file)
@@ -1192,7 +1192,7 @@ domain_port (const char *domain_b, const char *domain_e,
     ++p;                                       \
 } while (0)
 
-#define MARK_WORD(p, b, e) do {                        \
+#define SET_WORD_BOUNDARIES(p, b, e) do {                      \
   SKIP_WS (p);                                 \
   b = p;                                       \
   /* skip non-ws */                            \
@@ -1239,16 +1239,25 @@ load_cookies (const char *file)
        /* empty line */
        continue;
 
-      MARK_WORD (p, domain_b,  domain_e);
-      MARK_WORD (p, ignore_b,  ignore_e);
-      MARK_WORD (p, path_b,    path_e);
-      MARK_WORD (p, secure_b,  secure_e);
-      MARK_WORD (p, expires_b, expires_e);
-      MARK_WORD (p, name_b,    name_e);
+      SET_WORD_BOUNDARIES (p, domain_b,  domain_e);
+      SET_WORD_BOUNDARIES (p, ignore_b,  ignore_e);
+      SET_WORD_BOUNDARIES (p, path_b,    path_e);
+      SET_WORD_BOUNDARIES (p, secure_b,  secure_e);
+      SET_WORD_BOUNDARIES (p, expires_b, expires_e);
+      SET_WORD_BOUNDARIES (p, name_b,    name_e);
 
-      /* Don't use MARK_WORD for value because it may contain
-        whitespace itself.  Instead, . */
-      MARK_WORD (p, value_b,   value_e);
+      /* Don't use SET_WORD_BOUNDARIES for value because it may
+        contain whitespace.  Instead, set value_e to the end of line,
+        modulo trailing space (this will skip the line separator.) */
+      SKIP_WS (p);
+      value_b = p;
+      value_e = p + strlen (p);
+      while (value_e > value_b && ISSPACE (*(value_e - 1)))
+       --value_e;
+      if (value_b == value_e)
+       /* Hmm, should we check for empty value?  I guess that's
+          legal, so I leave it.  */
+       ;
 
       cookie = cookie_new ();
 
@@ -1269,19 +1278,6 @@ load_cookies (const char *file)
 
       cookie->domain  = strdupdelim (domain_b, domain_e);
 
-      /* Don't use MARK_WORD for value because it may contain
-        whitespace itself.  Instead, set name_e to the end of line,
-        modulo trailing space (which includes the NL separator.) */
-      SKIP_WS (p);
-      name_b = p;
-      name_e = p + strlen (p);
-      while (name_e >= name_b && ISSPACE (*name_e))
-       --name_e;
-      if (name_b == name_e)
-       /* Hmm, should we check for empty value?  I guess that's
-          legal, so I leave it.  */
-       ;
-
       /* safe default in case EXPIRES field is garbled. */
       cookie->expiry_time = cookies_now - 1;
 
index 42b2dbcb89c2cf67c1a575506eb9d320c41cb305..647442883a75686c981895502708b9e0a7265a16 100644 (file)
@@ -1381,7 +1381,10 @@ http_loop (struct urlinfo *u, char **newloc, int *dt)
      here so that we don't go through the hoops if we're just using
      FTP or whatever. */
   if (opt.cookies && opt.cookies_input && !cookies_loaded_p)
-    load_cookies (opt.cookies_input);
+    {
+      load_cookies (opt.cookies_input);
+      cookies_loaded_p = 1;
+    }
 
   *newloc = NULL;