]> sjero.net Git - wget/commitdiff
[svn] Check for wildcards in unescaped URL path.
authorhniksic <devnull@localhost>
Sun, 8 May 2005 17:52:26 +0000 (10:52 -0700)
committerhniksic <devnull@localhost>
Sun, 8 May 2005 17:52:26 +0000 (10:52 -0700)
src/ChangeLog
src/ftp.c
src/http.c

index 3fcc019f941e36b557d94cfa9d232c61bcf14d40..cd46298944c6425e737031abb7caaa803b7978b8 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-08  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * http.c (http_loop): Check for wildcards in the URL path
+       component, not in the whole URL.
+
+       * ftp.c (ftp_loop): Check for wildcards in URL path before
+       unescaping, so the users can escape globbing metacharacters with %
+       escapes.
+
 2005-05-08  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * init.c (run_command): Correctly interpret the return value of
index 9a77fc108bbd76bcd6ed5229830f6ff033b5fedb..4ec30a4ace67e0b9f4e7a438ee838321c6a56f1c 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1850,15 +1850,25 @@ ftp_loop (struct url *u, int *dt, struct url *proxy)
     }
   else
     {
-      int wild = has_wildcards_p (u->file);
-      if ((opt.ftp_glob && wild) || opt.recursive || opt.timestamping)
+      int ispattern = 0;
+      if (opt.ftp_glob)
+       {
+         /* Treat the URL as a pattern if the file name part of the
+            URL path contains wildcards.  (Don't check for u->file
+            because it is unescaped and therefore doesn't leave users
+            the option to escape literal '*' as %2A.)  */
+         char *file_part = strrchr (u->path, '/');
+         if (!file_part)
+           file_part = u->path;
+         ispattern = has_wildcards_p (file_part);
+       }
+      if (ispattern || opt.recursive || opt.timestamping)
        {
          /* ftp_retrieve_glob is a catch-all function that gets called
             if we need globbing, time-stamping or recursion.  Its
             third argument is just what we really need.  */
          res = ftp_retrieve_glob (u, &con,
-                                  (opt.ftp_glob && wild)
-                                  ? GLOB_GLOBALL : GLOB_GETONE);
+                                  ispattern ? GLOB_GLOBALL : GLOB_GETONE);
        }
       else
        res = ftp_loop_internal (u, NULL, &con);
index b7580335fa8729b5f9f41846f4d4cfdd70297b8e..d3fc1c3e8fe4bd5662784a277f77acd0ff13e5e7 100644 (file)
@@ -2004,10 +2004,8 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
 
   *newloc = NULL;
 
-  /* Warn on (likely bogus) wildcard usage in HTTP.  Don't use
-     has_wildcards_p because it would also warn on `?', and we know that
-     shows up in CGI paths a *lot*.  */
-  if (strchr (u->url, '*'))
+  /* Warn on (likely bogus) wildcard usage in HTTP.  */
+  if (has_wildcards_p (u->path))
     logputs (LOG_VERBOSE, _("Warning: wildcards not supported in HTTP.\n"));
 
   xzero (hstat);