[PATCH] Unescape login/password in URL

Clément Bœsch ubitux at gmail.com
Thu Nov 11 13:29:54 CET 2010


---
 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


--xtmLDbP6TiKhntQb--


More information about the MPlayer-dev-eng mailing list