[MPlayer-dev-eng] [PATCH 1/7] Unescape login/password before base64 encode
Clément Bœsch
ubitux at gmail.com
Mon Oct 18 12:05:51 CEST 2010
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 87dddc2..815992b 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, "Memory allocation failed\n");
+ 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, "Memory allocation failed\n");
+ 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
More information about the MPlayer-dev-eng
mailing list