[PATCH] Unescape login/password before base64 encode
Clément Bœsch
ubitux at gmail.com
Sun Oct 17 20:21:36 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 +++++++++++++++++++
stream/network.c | 6 ++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/stream/http.c b/stream/http.c
index a700d43..d4d4d58 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -607,9 +607,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);
}
@@ -648,6 +665,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 );
diff --git a/stream/network.c b/stream/network.c
index 37bfc00..c75feed 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -347,7 +347,8 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_NW_AuthRequired);
}
if( network_username ) {
- url->username = strdup(network_username);
+ url->username = malloc(strlen(network_username) * 3 + 1);
+ url_escape_string(url->username, network_username);
if( url->username==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
return -1;
@@ -357,7 +358,8 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
return -1;
}
if( network_password ) {
- url->password = strdup(network_password);
+ url->password = malloc(strlen(network_password) * 3 + 1);
+ url_escape_string(url->password, network_password);
if( url->password==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
return -1;
--
1.7.3.2
--wj9ZLJVQDRFjGSdK--
More information about the MPlayer-dev-eng
mailing list