From 52d3843079a4f05c60a19559ab0131a4304871ff Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Thu, 12 Jul 2012 22:23:27 +0200 Subject: [PATCH] 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. --- libcitadel/lib/urlhandling.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) -- 2.30.2