martin 98/04/01 05:55:31
Modified: src/modules/proxy proxy_util.c Log: A request like http://user:[EMAIL PROTECTED]/path would be rejected by the proxy_canon_netloc() routine if the caller (proxy_fixup in this case) would not be interested in the username/password. In this case, the url would be parsed incorrectly (the user:pass colon was misinterpreted as the :port part of the host). Now the parsing always allows for a user:pass@ part (but ignores it if the caller isn't interested). NOTE: all this crap should be cleaned up to use the parsed_uri values! Revision Changes Path 1.57 +22 -19 apache-1.3/src/modules/proxy/proxy_util.c Index: proxy_util.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -u -r1.56 -r1.57 --- proxy_util.c 1998/03/31 12:53:03 1.56 +++ proxy_util.c 1998/04/01 13:55:30 1.57 @@ -216,6 +216,7 @@ { int i; char *strp, *host, *url = *urlp; + char *user = NULL, *password = NULL; if (url[0] != '/' || url[1] != '/') return "Malformed URL"; @@ -226,33 +227,35 @@ else *(url++) = '\0'; /* skip seperating '/' */ - if (userp != NULL) { - char *user = NULL, *password = NULL; - strp = strchr(host, '@'); + /* find _last_ '@' since it might occur in user/password part */ + strp = strrchr(host, '@'); - if (strp != NULL) { - *strp = '\0'; - user = host; - host = strp + 1; + if (strp != NULL) { + *strp = '\0'; + user = host; + host = strp + 1; /* find password */ - strp = strchr(user, ':'); - if (strp != NULL) { - *strp = '\0'; - password = proxy_canonenc(p, strp + 1, strlen(strp + 1), enc_user, 1); - if (password == NULL) - return "Bad %-escape in URL (password)"; - } - - user = proxy_canonenc(p, user, strlen(user), enc_user, 1); - if (user == NULL) - return "Bad %-escape in URL (username)"; + strp = strchr(user, ':'); + if (strp != NULL) { + *strp = '\0'; + password = proxy_canonenc(p, strp + 1, strlen(strp + 1), enc_user, 1); + if (password == NULL) + return "Bad %-escape in URL (password)"; } + + user = proxy_canonenc(p, user, strlen(user), enc_user, 1); + if (user == NULL) + return "Bad %-escape in URL (username)"; + } + if (userp != NULL) { *userp = user; + } + if (passwordp != NULL) { *passwordp = password; } - strp = strchr(host, ':'); + strp = strrchr(host, ':'); if (strp != NULL) { *(strp++) = '\0';