From 0aa4cc9ec67f2b4d3c802c65655091e1abc06857 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 13 Jul 2012 11:34:02 +0200 Subject: [PATCH] URL-Handling: de-Url-Escapify username and Passwords. --- libcitadel/lib/libcitadel.h | 2 ++ libcitadel/lib/urlhandling.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index a110baf25..71d2ec8f2 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -392,6 +392,8 @@ struct ParsedURL { struct sockaddr_in6 Addr; ParsedURL *Next; int IsRelay; + StrBuf *UsrName; + StrBuf *Password; }; void FreeURL(ParsedURL** Url); diff --git a/libcitadel/lib/urlhandling.c b/libcitadel/lib/urlhandling.c index f350ea7d4..4cca8a1f5 100644 --- a/libcitadel/lib/urlhandling.c +++ b/libcitadel/lib/urlhandling.c @@ -26,6 +26,8 @@ void FreeURL(ParsedURL** Url) FreeStrBuf(&(*Url)->URL); FreeStrBuf(&(*Url)->UrlWithoutCred); FreeStrBuf(&(*Url)->CurlCreds); + FreeStrBuf(&(*Url)->UsrName); + FreeStrBuf(&(*Url)->Password); if ((*Url)->Next != NULL) FreeURL(&(*Url)->Next); free(*Url); @@ -131,6 +133,19 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) ((struct sockaddr_in *)&(url->Addr))->sin_family = AF_INET; } } + + if (url->User != NULL) { + url->UsrName = NewStrBufPlain(url->User, pUserEnd - url->User); + StrBufUnescape(url->UsrName, 0); + url->User = ChrPtr(url->UsrName); + } + + if (url->Pass != NULL) { + url->Password = NewStrBufPlain(url->Pass, pCredEnd - url->Pass); + StrBufUnescape(url->Password, 0); + url->Pass = ChrPtr(url->Password); + } + if (*Url != NULL) url->Next = *Url; *Url = url; -- 2.30.2