]> sjero.net Git - wget/blobdiff - src/cookies.c
[svn] Fix K&R incompatibilities reported by `gcc -Wtraditional'.
[wget] / src / cookies.c
index d0d9e6101e3c4930b210aee19aaa8a53acad0753..eb3f879f5716ab6fe071b4080c49a8ff414f43a6 100644 (file)
@@ -870,9 +870,19 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
     }
 
   if (!cookie->path)
-    cookie->path = xstrdup (path);
+    {
+      /* The cookie doesn't set path: set it to the URL path, sans the
+        file part ("/dir/file" truncated to "/dir/").  */
+      char *trailing_slash = strrchr (path, '/');
+      if (trailing_slash)
+       cookie->path = strdupdelim (path, trailing_slash + 1);
+      else
+       /* no slash in the string -- can this even happen? */
+       cookie->path = xstrdup (path);
+    }
   else
     {
+      /* The cookie sets its own path; verify that it is legal. */
       if (!check_path_match (cookie->path, path))
        {
          DEBUGP (("Attempt to fake the path: %s, %s\n",
@@ -881,6 +891,9 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
        }
     }
 
+  /* Now store the cookie, or discard an existing cookie, if
+     discarding was requested.  */
+
   if (cookie->discard_requested)
     {
       discard_matching_cookie (jar, cookie);
@@ -1391,7 +1404,7 @@ cookie_jar_load (struct cookie_jar *jar, const char *file)
       else
        {
          if (expiry < cookies_now)
-           goto abort;         /* ignore stale cookie. */
+           goto abort_cookie;  /* ignore stale cookie. */
          cookie->expiry_time = expiry;
          cookie->permanent = 1;
        }
@@ -1401,7 +1414,7 @@ cookie_jar_load (struct cookie_jar *jar, const char *file)
     next:
       continue;
 
-    abort:
+    abort_cookie:
       delete_cookie (cookie);
     }
   fclose (fp);