[svn] Applied Jan's patch to allow non-quoted @ character in

passwords.  Published in <20010106173455.A9455@erwin.telekabel.at>.
This commit is contained in:
hniksic 2001-02-10 16:28:22 -08:00
parent 18d476b8d0
commit 54811e2832
2 changed files with 17 additions and 10 deletions

View 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-Aørn <hack@hackdata.com>-B 2001-02-11 Hack Kampbj-Aørn <hack@hackdata.com>-B
* url.c (parseurl): Debug-print u->ftp_type. * url.c (parseurl): Debug-print u->ftp_type.

View File

@ -339,13 +339,13 @@ int
skip_uname (const char *url) skip_uname (const char *url)
{ {
const char *p; const char *p;
for (p = url; *p && *p != '/'; p++) const char *q = NULL;
if (*p == '@') for (p = url ; *p && *p != '/'; p++)
break; if (*p == '@') q = p;
/* If a `@' was found before the first occurrence of `/', skip /* If a `@' was found before the first occurrence of `/', skip
it. */ it. */
if (*p == '@') if (q != NULL)
return p - url + 1; return q - url + 1;
else else
return 0; return 0;
} }
@ -608,7 +608,7 @@ static uerr_t
parse_uname (const char *url, char **user, char **passwd) parse_uname (const char *url, char **user, char **passwd)
{ {
int l; int l;
const char *p, *col; const char *p, *q, *col;
char **where; char **where;
*user = NULL; *user = NULL;
@ -628,7 +628,7 @@ parse_uname (const char *url, char **user, char **passwd)
if (*p != '@') if (*p != '@')
return URLOK; return URLOK;
/* Else find the username and password. */ /* Else find the username and password. */
for (p = col = url; *p != '@'; p++) for (p = q = col = url; *p != '/'; p++)
{ {
if (*p == ':' && !*user) if (*p == ':' && !*user)
{ {
@ -637,12 +637,13 @@ parse_uname (const char *url, char **user, char **passwd)
(*user)[p - url] = '\0'; (*user)[p - url] = '\0';
col = p + 1; col = p + 1;
} }
if (*p == '@') q = p;
} }
/* Decide whether you have only the username or both. */ /* Decide whether you have only the username or both. */
where = *user ? passwd : user; where = *user ? passwd : user;
*where = (char *)xmalloc (p - col + 1); *where = (char *)xmalloc (q - col + 1);
memcpy (*where, col, p - col); memcpy (*where, col, q - col);
(*where)[p - col] = '\0'; (*where)[q - col] = '\0';
return URLOK; return URLOK;
} }