1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

allow zero length user names for http

This commit is contained in:
Daniel Stenberg 2000-08-08 13:46:26 +00:00
parent 0d7cce1f08
commit 8fd44dd648

View File

@ -733,37 +733,42 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
if(data->bits.user_passwd && !data->bits.use_netrc) { if(data->bits.user_passwd && !data->bits.use_netrc) {
if(':' != *data->userpwd) { data->user[0] =0;
if((1 <= sscanf(data->userpwd, "%127[^:]:%127s", data->passwd[0]=0;
data->user, data->passwd))) {
/* check for password, if no ask for one */ if(*data->userpwd != ':') {
if( !data->passwd[0] ) /* the name is given, get user+password */
{ sscanf(data->userpwd, "%127[^:]:%127[^@]",
strncpy(data->passwd, getpass("password: "), sizeof(data->passwd)); data->user, data->passwd);
}
} }
} else
if(!data->user[0]) { /* no name given, get the password only */
failf(data, "USER malformat: user name can't be zero length"); sscanf(data->userpwd+1, "%127[^@]", data->passwd);
return CURLE_MALFORMAT_USER;
/* check for password, if no ask for one */
if( !data->passwd[0] ) {
strncpy(data->passwd, getpass("password: "), sizeof(data->passwd));
} }
} }
if(data->bits.proxy_user_passwd) { if(data->bits.proxy_user_passwd) {
if(':' != *data->proxyuserpwd) { data->proxyuser[0] =0;
if((1 <= sscanf(data->proxyuserpwd, "%127[^:]:%127s", data->proxypasswd[0]=0;
data->proxyuser, data->proxypasswd))) {
/* check for password, if no ask for one */ if(*data->proxyuserpwd != ':') {
if( !data->proxypasswd[0] ) /* the name is given, get user+password */
{ sscanf(data->proxyuserpwd, "%127[^:]:%127[^@]",
strncpy(data->proxypasswd, getpass("proxy password: "), sizeof(data->proxypasswd)); data->proxyuser, data->proxypasswd);
}
} }
else
/* no name given, get the password only */
sscanf(data->proxyuserpwd+1, "%127[^@]", data->proxypasswd);
/* check for password, if no ask for one */
if( !data->proxypasswd[0] ) {
strncpy(data->proxypasswd, getpass("proxy password: "), sizeof(data->proxypasswd));
} }
if(!data->proxyuser[0]) {
failf(data, " Proxy USER malformat: user name can't be zero length");
return CURLE_MALFORMAT_USER;
}
} }
conn->name = conn->gname; conn->name = conn->gname;
@ -1038,13 +1043,32 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
user+password pair in a string like: user+password pair in a string like:
ftp://user:password@ftp.my.site:8021/README */ ftp://user:password@ftp.my.site:8021/README */
char *ptr=NULL; /* assign to remove possible warnings */ char *ptr=NULL; /* assign to remove possible warnings */
#if 0
if(':' == *conn->name) { if(':' == *conn->name) {
failf(data, "URL malformat: user can't be zero length"); failf(data, "URL malformat: user can't be zero length");
return CURLE_URL_MALFORMAT_USER; return CURLE_URL_MALFORMAT_USER;
} }
if((1 <= sscanf(conn->name, "%127[^:]:%127[^@]", #endif
data->user, data->passwd)) && if(ptr=strchr(conn->name, '@')) {
(ptr=strchr(conn->name, '@'))) { /* there's a user+password given here, to the left of the @ */
data->user[0] =0;
data->passwd[0]=0;
if(*conn->name != ':') {
/* the name is given, get user+password */
sscanf(conn->name, "%127[^:]:%127[^@]",
data->user, data->passwd);
}
else
/* no name given, get the password only */
sscanf(conn->name+1, "%127[^@]", data->passwd);
/* check for password, if no ask for one */
if( !data->passwd[0] ) {
strncpy(data->passwd, getpass("password: "), sizeof(data->passwd));
}
conn->name = ++ptr; conn->name = ++ptr;
data->bits.user_passwd=1; /* enable user+password */ data->bits.user_passwd=1; /* enable user+password */
} }