]> sjero.net Git - wget/blobdiff - src/cookies.c
[svn] Allow trailing whitespace in Set-Cookies. Also allow empty Set-Cookies
[wget] / src / cookies.c
index c31a286524da6aa6532714cc9395a1bf1f5ef1f7..48e62c8322eaac4816ae3b2e2216a08f5bacae03 100644 (file)
@@ -466,15 +466,17 @@ parse_set_cookies (const char *sc)
   const char *name_b  = NULL, *name_e  = NULL;
   const char *value_b = NULL, *value_e = NULL;
 
-  FETCH (c, p);
-
   while (state != S_DONE && state != S_ERROR)
     {
       switch (state)
        {
        case S_NAME_PRE:
-         if (ISSPACE (c))
-           FETCH (c, p);
+         /* Strip whitespace preceding the name. */
+         do
+           FETCH1 (c, p);
+         while (c && ISSPACE (c));
+         if (!c)
+           state = S_DONE;
          else if (ATTR_NAME_CHAR (c))
            {
              name_b = p - 1;
@@ -589,13 +591,7 @@ parse_set_cookies (const char *sc)
                state = S_ERROR;
                break;
              }
-
-           if (c)
-             FETCH1 (c, p);
-           if (!c)
-             state = S_DONE;
-           else
-             state = S_NAME_PRE;
+           state = S_NAME_PRE;
          }
          break;
        case S_DONE: