]> sjero.net Git - wget/blobdiff - src/url.c
Automated merge with file:/home/micah/devel/wget/fix-double-gets
[wget] / src / url.c
index 04ecb3a4f3429170bf0c574df531264edcb77023..72bb7b90d735c6eca5a73a450dda6b0d4e60a1cf 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -1,5 +1,6 @@
 /* URL handling.
-   Copyright (C) 1996-2007 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -1939,10 +1940,7 @@ getchar_from_escaped_string (const char *str, char *c)
   
   if (p[0] == '%')
     {
-      if (p[1] == 0)
-        return 0; /* error: invalid string */
-
-      if (p[1] == '%')
+      if (!ISXDIGIT(p[1]) || !ISXDIGIT(p[2]))
         {
           *c = '%';
           return 1;
@@ -1953,8 +1951,13 @@ getchar_from_escaped_string (const char *str, char *c)
             return 0; /* error: invalid string */
 
           *c = X2DIGITS_TO_NUM (p[1], p[2]);
-
-          return 3;
+          if (URL_RESERVED_CHAR(*c))
+            {
+              *c = '%';
+              return 1;
+            }
+          else
+            return 3;
         }
     }
   else
@@ -1971,11 +1974,12 @@ are_urls_equal (const char *u1, const char *u2)
   const char *p, *q;
   int pp, qq;
   char ch1, ch2;
+  assert(u1 && u2);
 
   p = u1;
   q = u2;
 
-  while (*p 
+  while (*p && *q
          && (pp = getchar_from_escaped_string (p, &ch1))
          && (qq = getchar_from_escaped_string (q, &ch2))
          && (TOLOWER(ch1) == TOLOWER(ch2)))
@@ -2111,6 +2115,8 @@ test_are_urls_equal()
     { "http://www.adomain.com/apath/", "http://www.adomain.com/anotherpath/", false },
     { "http://www.adomain.com/apath/", "http://www.anotherdomain.com/path/",  false },
     { "http://www.adomain.com/~path/", "http://www.adomain.com/%7epath/",     true },
+    { "http://www.adomain.com/longer-path/", "http://www.adomain.com/path/",  false },
+    { "http://www.adomain.com/path%2f", "http://www.adomain.com/path/",       false },
   };
   
   for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i)