>From 6c5d6ac43bdeaba7f5ce9efb43fa8314c88ca6fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Thu, 11 Nov 2010 13:29:54 +0100 Subject: [PATCH] Unescape login/password in URL --- stream/url.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/stream/url.c b/stream/url.c index a32287f..4d6bdd8 100644 --- a/stream/url.c +++ b/stream/url.c @@ -58,6 +58,34 @@ URL_t *url_redirect(URL_t **url, const char *redir) { return res; } +static int url_unescape_userpass(URL_t *url) +{ + char *tmp; + + if (url->username) { + tmp = malloc(strlen(url->username) + 1); + if (tmp == NULL) + goto err; + url_unescape_string(tmp, url->username); + free(url->username); + url->username = tmp; + + if (url->password) { + tmp = malloc(strlen(url->password) + 1); + if (tmp == NULL) + goto err; + url_unescape_string(tmp, url->password); + free(url->password); + url->password = tmp; + } + } + return 0; + +err: + mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed); + return -1; +} + URL_t* url_new(const char* url) { int pos1, pos2,v6addr = 0; @@ -158,6 +186,9 @@ url_new(const char* url) { pos1 = ptr1-escfilename; } + if (url_unescape_userpass(Curl) < 0) + goto err_out; + // before looking for a port number check if we have an IPv6 type numeric address // in IPv6 URL the numeric address should be inside square braces. ptr2 = strstr(ptr1, "["); -- 1.7.3.2