]> sjero.net Git - wget/commitdiff
[svn] retr.c (retrieve_url): Manually applied T. Bharath
authordan <devnull@localhost>
Sat, 28 Oct 2000 03:18:20 +0000 (20:18 -0700)
committerdan <devnull@localhost>
Sat, 28 Oct 2000 03:18:20 +0000 (20:18 -0700)
<TBharath@responsenetworks.com>'s patch to get wget to grok illegal relative URL
redirects.  Reformatted and re-commented it.

ChangeLog
TODO
src/ChangeLog
src/retr.c

index 164fadac71401537aac97c8b4a312039c3db8ee5..f226deab770ad30d795b9f46141a3097a8025d67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2000-10-27  Dan Harkless  <dan-wget@dilvish.speed.net>
+
+       * TODO: wget now groks illegal relative URL HTTP redirects.
+
 2000-10-24  Dan Harkless  <dan-wget@dilvish.speed.net>
 
        * NEWS: Forgot to update regarding new --bind-address option.
diff --git a/TODO b/TODO
index 95d8c0385926000e85483d65b92b110573fb82df..a1dcd0a7b15d9051136071033d2ec7652f8eed31 100644 (file)
--- a/TODO
+++ b/TODO
@@ -28,9 +28,6 @@ may tend towards the top).  Not all of these represent user-visible changes.
 
 * --retr-symlinks should cause wget to traverse links to directories too.
 
-* Lots of noncompliant webservers issue HTTP redirects to relative URLs, and
-  browsers follow them, so wget should too.
-
 * Make wget return non-zero status in more situations, like incorrect HTTP auth.
 
 * Timestamps are sometimes not copied over on files retrieved by FTP.
index b2770ef7e4219ce0d7b13cd007d93bdacbf2c90e..95761f72928f27e82e649e307be31fbaa5710ab4 100644 (file)
@@ -1,3 +1,9 @@
+2000-10-27  Dan Harkless  <dan-wget@dilvish.speed.net>
+
+       * retr.c (retrieve_url): Manually applied T. Bharath
+       <TBharath@responsenetworks.com>'s patch to get wget to grok
+       illegal relative URL redirects.  Reformatted and re-commented it.
+
 2000-10-23  Dan Harkless  <dan-wget@dilvish.speed.net>
 
        * connect.c (make_connection and bindport): Manually applied Rob
index 7e884f1b3cb4bef1e48b35e04124159b664cf867..8fa76175edfb7bf1cdfaa141467b20c9b40031f0 100644 (file)
@@ -406,6 +406,28 @@ retrieve_url (const char *origurl, char **file, char **newloc,
        }
       if (mynewloc)
        {
+         /* The HTTP specs only allow absolute URLs to appear in redirects, but
+            a ton of boneheaded webservers and CGIs out there break the rules
+            and use relative URLs, and popular browsers are lenient about this,
+            so wget should be too. */
+         if (strstr(mynewloc, "://") == NULL)
+           /* Doesn't look like an absolute URL (this check will incorrectly
+              think that rare relative URLs containing "://" later in the
+              string are absolute). */
+           {
+             char *temp = malloc(strlen(url) + strlen(mynewloc) + 1);
+             
+             if (mynewloc[0] == '/')
+               /* "Hostless absolute" URL.  Convert to absolute. */
+               sprintf(temp,"%s%s", url, mynewloc);
+             else
+               /* Relative URL.  Convert to absolute. */
+               sprintf(temp,"%s/%s", url, mynewloc);
+
+             free(mynewloc);
+             mynewloc = temp;
+           }
+         
          free (url);
          url = mynewloc;
        }