On 7/16/07, Jaymz Goktug YUKSEL <[EMAIL PROTECTED]> wrote:
Hello everyone,

                                        Is there a command to override the
maximum redirections?

Attached is a patch for this problem. Let me know if you have any
problems with it. It was written for the latest trunk in the svn, so
you *may* have to compile an unstable release.

You can browse the source (with this patch) at
<http://addictivecode.org/svn/wget/branches/bugs/b20499/>. To download
it, run:

svn co svn://addictivecode.org/wget/branches/bugs/b20499 wget-maxredirect

To compile, run:

./autogen.sh
./configure
make

As this is an unstable release, you probably do not wish to install
it, but to run it from ./src/wget with the --max-redirect option.
Index: src/options.h
===================================================================
--- src/options.h	(revision 2280)
+++ src/options.h	(working copy)
@@ -38,6 +38,8 @@
   bool recursive;		/* Are we recursive? */
   bool spanhost;			/* Do we span across hosts in
 				   recursion? */
+  int  maxredirect;            /* 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: src/init.c
===================================================================
--- src/init.c	(revision 2280)
+++ src/init.c	(working copy)
@@ -182,6 +182,7 @@
   { "loadcookies",	&opt.cookies_input,	cmd_file },
   { "logfile",		&opt.lfilename,		cmd_file },
   { "login",		&opt.ftp_user,		cmd_string },/* deprecated*/
+  { "maxredirect",	&opt.maxredirect,	cmd_number_inf },
   { "mirror",		NULL,			cmd_spec_mirror },
   { "netrc",		&opt.netrc,		cmd_boolean },
   { "noclobber",	&opt.noclobber,		cmd_boolean },
Index: src/retr.c
===================================================================
--- src/retr.c	(revision 2280)
+++ src/retr.c	(working copy)
@@ -567,13 +567,7 @@
   return dlrate;
 }
 
-/* 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;			\
   saved_post_data = opt.post_data;		\
@@ -746,10 +740,10 @@
       mynewloc = xstrdup (newloc_parsed->url);
 
       /* Check for max. number of redirections.  */
-      if (++redirection_count > MAX_REDIRECTIONS)
+      if (++redirection_count > opt.maxredirect)
 	{
 	  logprintf (LOG_NOTQUIET, _("%d redirections exceeded.\n"),
-		     MAX_REDIRECTIONS);
+		     opt.maxredirect);
 	  url_free (newloc_parsed);
 	  url_free (u);
 	  xfree (url);
Index: src/main.c
===================================================================
--- src/main.c	(revision 2280)
+++ src/main.c	(working copy)
@@ -189,6 +189,7 @@
     { "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 },
@@ -497,6 +498,8 @@
     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_("\
        --proxy-password=PASS   set PASS as proxy password.\n"),
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2280)
+++ ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2007-07-16  Joshua David Williams <[EMAIL PROTECTED]>
+
+	* Added new option --max-redirect
+
 2007-07-09  Micah Cowan  <[EMAIL PROTECTED]>
 
 	* README, util/wget.spec: Removed references to wget.sunsite.dk.

Reply via email to