]> sjero.net Git - wget/commitdiff
[svn] Applied Jan's patch to allow non-quoted @ character in
authorhniksic <devnull@localhost>
Sun, 11 Feb 2001 00:28:22 +0000 (16:28 -0800)
committerhniksic <devnull@localhost>
Sun, 11 Feb 2001 00:28:22 +0000 (16:28 -0800)
passwords.  Published in <20010106173455.A9455@erwin.telekabel.at>.

src/ChangeLog
src/url.c

index 5b3c00a945c59d21f3f7b38dfc991e29d49074f7..3178b8aef0779f39c8499cbbbd622c953316adc0 100644 (file)
@@ -1,3 +1,9 @@
+2001-01-06  Jan Prikryl  <prikryl@cg.tuwien.ac.at>
+
+       * url.c (parse_uname): Added support for passwords containing '@'
+       characters.
+       (skip_uname): Ditto.
+
 2001-02-11  Hack Kampbj\e-Aørn  <hack@hackdata.com>\e-B
 
        * url.c (parseurl): Debug-print u->ftp_type.
index ea3b645388d77aaf3418d8386bc08f2870566784..4c8f35aafe00dc41998d5457ed84ccd44e9af9d4 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -339,13 +339,13 @@ int
 skip_uname (const char *url)
 {
   const char *p;
-  for (p = url; *p && *p != '/'; p++)
-    if (*p == '@')
-      break;
+  const char *q = NULL;
+  for (p = url ; *p && *p != '/'; p++)
+    if (*p == '@') q = p;
   /* If a `@' was found before the first occurrence of `/', skip
      it.  */
-  if (*p == '@')
-    return p - url + 1;
+  if (q != NULL)
+    return q - url + 1;
   else
     return 0;
 }
@@ -608,7 +608,7 @@ static uerr_t
 parse_uname (const char *url, char **user, char **passwd)
 {
   int l;
-  const char *p, *col;
+  const char *p, *q, *col;
   char **where;
 
   *user = NULL;
@@ -628,7 +628,7 @@ parse_uname (const char *url, char **user, char **passwd)
   if (*p != '@')
     return URLOK;
   /* Else find the username and password.  */
-  for (p = col = url; *p != '@'; p++)
+  for (p = q = col = url; *p != '/'; p++)
     {
       if (*p == ':' && !*user)
        {
@@ -637,12 +637,13 @@ parse_uname (const char *url, char **user, char **passwd)
          (*user)[p - url] = '\0';
          col = p + 1;
        }
+      if (*p == '@') q = p;
     }
   /* Decide whether you have only the username or both.  */
   where = *user ? passwd : user;
-  *where = (char *)xmalloc (p - col + 1);
-  memcpy (*where, col, p - col);
-  (*where)[p - col] = '\0';
+  *where = (char *)xmalloc (q - col + 1);
+  memcpy (*where, col, q - col);
+  (*where)[q - col] = '\0';
   return URLOK;
 }