diff options
author | Michał Cichoń <michcic@gmail.com> | 2017-05-18 18:28:05 +0200 |
---|---|---|
committer | Michał Cichoń <michcic@gmail.com> | 2017-05-18 18:28:05 +0200 |
commit | 091d717658fa765e4486c5644343a0aec4373a9c (patch) | |
tree | 21f4419d9dceae3226286585b8b5ca87ea1934ce /src/http | |
parent | aa2d42f83607d7eae63cc7d860b919e60e1defd8 (diff) | |
parent | cd5c65097ecf03480f477e47e0bb706dbf705a21 (diff) | |
download | pianobar-windows-091d717658fa765e4486c5644343a0aec4373a9c.tar.gz pianobar-windows-091d717658fa765e4486c5644343a0aec4373a9c.tar.bz2 pianobar-windows-091d717658fa765e4486c5644343a0aec4373a9c.zip |
Merge tag '2017.05.18' into develop
2017.05.18
* Synchronize with upstream
* Fixed: Handle escaped authority url components. pianobar-windows-binaries/#3
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/http.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/http/http.c b/src/http/http.c index 609317f..4576d04 100644 --- a/src/http/http.c +++ b/src/http/http.c @@ -250,6 +250,32 @@ bool HttpSetAutoProxy (http_t http, const char* url) { return false; } +static void HttpUrlDecodeInplace (wchar_t* url) +{ + wchar_t* input = url; + wchar_t* output = url; + size_t size = wcslen (url); + while (size > 0) { + if (input[0] == '%' && iswxdigit(input[1]) && iswxdigit(input[2])) { + wchar_t hex[3]; + hex[0] = input[1]; + hex[1] = input[2]; + hex[2] = 0; + *output++ = (wchar_t)(wcstol (hex, NULL, 16)); + input += 3; + size -= 3; + } + else { + *output++ = *input++; + --size; + } + } + + if (output < input) { + *output = '\0'; + } +} + bool HttpSetProxy (http_t http, const char* url) { URL_COMPONENTS urlComponents; wchar_t* wideUrl = NULL; @@ -267,10 +293,12 @@ bool HttpSetProxy (http_t http, const char* url) { if (urlComponents.lpszUserName && urlComponents.dwUserNameLength > 0) { wideUsername = wcsdup(urlComponents.lpszUserName); wideUsername[urlComponents.dwUserNameLength] = 0; + HttpUrlDecodeInplace (wideUsername); } if (urlComponents.lpszPassword && urlComponents.dwPasswordLength > 0) { widePassword = wcsdup(urlComponents.lpszPassword); widePassword[urlComponents.dwPasswordLength] = 0; + HttpUrlDecodeInplace (widePassword); } } |