>From 23832fe7775f0030560f8fee5865a2e3bf72fcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 17 Oct 2010 20:21:36 +0200 Subject: [PATCH 3/8] Unescape login/password before base64 encode I already sent it in a previous mail: it allows login/password to be unescaped before base64 encode so auth with special characters now works. --- stream/http.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/stream/http.c b/stream/http.c index ad39b8f..7c48bdc 100644 --- a/stream/http.c +++ b/stream/http.c @@ -608,9 +608,26 @@ http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, co char *auth = NULL, *usr_pass = NULL, *b64_usr_pass = NULL; int encoded_len, pass_len=0, out_len; int res = -1; + char *username_decoded = NULL, *password_decoded = NULL; + if( http_hdr==NULL || username==NULL ) return -1; + username_decoded = malloc(strlen(username) + 1); + if (username_decoded == NULL) { + mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed); + goto out; + } + url_unescape_string(username_decoded, username); + username = username_decoded; + if( password!=NULL ) { + password_decoded = malloc(strlen(password) + 1); + if (password_decoded == NULL) { + mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed); + goto out; + } + url_unescape_string(password_decoded, password); + password = password_decoded; pass_len = strlen(password); } @@ -649,6 +666,8 @@ http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, co res = 0; out: + free(username_decoded); + free(password_decoded); free( usr_pass ); free( b64_usr_pass ); free( auth ); -- 1.7.3.1