From: Wilfried Goesgens Date: Thu, 12 Jul 2012 20:23:27 +0000 (+0200) Subject: URL-Parser: fix parsing of Usernames with @ X-Git-Tag: v8.13~10 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=52d3843079a4f05c60a19559ab0131a4304871ff URL-Parser: fix parsing of Usernames with @ - we previously would use strch to find the first @ in the URL - when there is an @ inside of the username this one would be hit. - since we first search for the end of the host-path, we can search from the right for the last @ to separate the user:auth from the real hostname. --- diff --git a/libcitadel/lib/urlhandling.c b/libcitadel/lib/urlhandling.c index 131cafa6e..49878afda 100644 --- a/libcitadel/lib/urlhandling.c +++ b/libcitadel/lib/urlhandling.c @@ -53,12 +53,12 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) */ url->URL = NewStrBufDup(UrlStr); url->Host = pch = ChrPtr(url->URL); - url->LocalPart = strchr(pch, '/'); + pEndHost = url->LocalPart = strchr(pch, '/'); if (url->LocalPart != NULL) { if ((*(url->LocalPart + 1) == '/') && (*(url->LocalPart - 1) == ':')) { /* TODO: find default port for this protocol... */ url->Host = url->LocalPart + 2; - url->LocalPart = strchr(url->Host, '/'); + pEndHost = url->LocalPart = strchr(url->Host, '/'); if (url->LocalPart != NULL) { StrBufPeek(url->URL, url->LocalPart, 0, '\0'); @@ -67,10 +67,10 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) } } if (url->LocalPart == NULL) { - url->LocalPart = pch + StrLength(url->URL); + pEndHost = url->LocalPart = ChrPtr(url->URL) + StrLength(url->URL); } - pCredEnd = strchr(pch, '@'); + pCredEnd = strrchr(ChrPtr(url->URL), '@'); if (pCredEnd >= url->LocalPart) pCredEnd = NULL; if (pCredEnd != NULL)