]> sjero.net Git - wget/commitdiff
[svn] Merging fix #20499: MAX_REDIRECTIONS should be configurable.
authormicah <devnull@localhost>
Sun, 29 Jul 2007 02:37:14 +0000 (19:37 -0700)
committermicah <devnull@localhost>
Sun, 29 Jul 2007 02:37:14 +0000 (19:37 -0700)
doc/ChangeLog
doc/wget.texi
src/ChangeLog
src/init.c
src/main.c
src/options.h
src/retr.c

index 0ac5628a76c06fc73300690f05139a993994611d..3b16b9f33e5fc863c5478105aeb3e6b765722a68 100644 (file)
@@ -1,3 +1,7 @@
+2007-07-28  Micah Cowan  <micah@cowan.name>
+
+       * wget.texi <HTTP Options>: Added --max-redirect option.
+
 2007-07-05  Micah Cowan  <micah@cowan.name>
 
        * fdl.texi:
index bd4c39164daa6681d7f8671db4eeccb97feff3f2..fcc5cd603467c4ef44c01669c626e50ea7c1ea31 100644 (file)
@@ -1239,6 +1239,13 @@ wget --header="Host: foo.bar" http://localhost/
 In versions of Wget prior to 1.10 such use of @samp{--header} caused
 sending of duplicate headers.
 
+@cindex redirect
+@item --max-redirect=@var{number}
+Specifies the maximum number of redirections to follow for a resource.
+The default is 20, which is usually far more than necessary. However, on
+those occasions where you want to allow more (or fewer), this is the
+option to use.
+
 @cindex proxy user
 @cindex proxy password
 @cindex proxy authentication
index 69faa6722843b78244729c74a617b45dc2922e51..4dc66b1f4f5c3eb130022c69a95ac9f9c48e7f4f 100644 (file)
@@ -1,3 +1,20 @@
+2007-07-28  Micah Cowan  <micah@cowan.name>
+
+       * options.h, init.c, retr.c, main.c: renamed opt maxredirect
+       field to max_redirect, for improved consistency.
+       * init.c: changed max_redirect parser from cmd_number_inf to
+       cmd_number, as infinite redirects may not be appropriate.
+       Alternatively, if cmd_number_inf should be used, then
+       opt.max_redirect's value should be checked a bit differently in
+       retr.c, to allow for the "infinite" meaning of zero.
+
+2007-07-16  Joshua David Williams  <yurimxpxman@gmail.com>
+
+       * options.h: added maxredirect to options struct
+       * init.c: added maxredirect to list of variables
+       * retr.c (retrieve_url): replaced MAX_REDIRECTIONS with opt.maxredirect
+       * main.c: added option --max-redirect
+
 2007-07-16  Joshua David Williams  <yurimxpxman@gmail.com>
 
        * test.h: tests made more verbose; now displays the name
index 6ad97f3645100b745090c6e21ac5789cd4b519e9..7f8115638425e0785205afacd99a36b85aa28edd 100644 (file)
@@ -182,6 +182,7 @@ static struct {
   { "loadcookies",     &opt.cookies_input,     cmd_file },
   { "logfile",         &opt.lfilename,         cmd_file },
   { "login",           &opt.ftp_user,          cmd_string },/* deprecated*/
+  { "maxredirect",     &opt.max_redirect,      cmd_number },
   { "mirror",          NULL,                   cmd_spec_mirror },
   { "netrc",           &opt.netrc,             cmd_boolean },
   { "noclobber",       &opt.noclobber,         cmd_boolean },
@@ -321,6 +322,7 @@ defaults (void)
   opt.restrict_files_case = restrict_no_case_restriction;
 
   opt.content_disposition = true;
+  opt.max_redirect = 20;
 }
 \f
 /* Return the user's home directory (strdup-ed), or NULL if none is
index 9a30bbf7aa289cbd1c6f59091e993b6372a210a5..ab1786d7695fc9fdc6915c729344b5e2ff939c38 100644 (file)
@@ -189,6 +189,7 @@ static struct cmdline_option option_data[] =
     { "level", 'l', OPT_VALUE, "reclevel", -1 },
     { "limit-rate", 0, OPT_VALUE, "limitrate", -1 },
     { "load-cookies", 0, OPT_VALUE, "loadcookies", -1 },
+    { "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
     { "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
     { "no", 'n', OPT__NO, NULL, required_argument },
     { "no-clobber", 0, OPT_BOOLEAN, "noclobber", -1 },
@@ -496,6 +497,8 @@ HTTP options:\n"),
        --ignore-length         ignore `Content-Length' header field.\n"),
     N_("\
        --header=STRING         insert STRING among the headers.\n"),
+    N_("\
+       --max-redirect          maximum redirections allowed per page.\n"),
     N_("\
        --proxy-user=USER       set USER as proxy username.\n"),
     N_("\
index 0267e37668c0e08c89274f67888c53e056da2677..7fda95e3a47098ad010ea328c24beff0345f2d86 100644 (file)
@@ -36,8 +36,10 @@ struct options
   bool background;             /* Whether we should work in background. */
   bool ignore_length;          /* Do we heed content-length at all?  */
   bool recursive;              /* Are we recursive? */
-  bool spanhost;                       /* Do we span across hosts in
+  bool spanhost;               /* Do we span across hosts in
                                   recursion? */
+  int  max_redirect;            /* Maximum number of times we'll allow
+                                   a page to redirect. */
   bool relative_only;          /* Follow only relative links. */
   bool no_parent;              /* Restrict access to the parent
                                   directory.  */
index c531be59c35bae44344c14e9b661a8c9af05b558..92494fc9722599247966a89faec902ea7cc0e441 100644 (file)
@@ -567,12 +567,6 @@ calc_rate (wgint bytes, double secs, int *units)
   return dlrate;
 }
 \f
-/* Maximum number of allowed redirections.  20 was chosen as a
-   "reasonable" value, which is low enough to not cause havoc, yet
-   high enough to guarantee that normal retrievals will not be hurt by
-   the check.  */
-
-#define MAX_REDIRECTIONS 20
 
 #define SUSPEND_POST_DATA do {                 \
   post_data_suspended = true;                  \
@@ -746,10 +740,10 @@ retrieve_url (const char *origurl, char **file, char **newloc,
       mynewloc = xstrdup (newloc_parsed->url);
 
       /* Check for max. number of redirections.  */
-      if (++redirection_count > MAX_REDIRECTIONS)
+      if (++redirection_count > opt.max_redirect)
        {
          logprintf (LOG_NOTQUIET, _("%d redirections exceeded.\n"),
-                    MAX_REDIRECTIONS);
+                    opt.max_redirect);
          url_free (newloc_parsed);
          url_free (u);
          xfree (url);