aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/httpauth.c
diff options
context:
space:
mode:
authorAntti Seppälä <a.seppala+libav-devel@gmail.com>2012-07-25 12:43:39 +0300
committerMartin Storsjö <martin@martin.st>2012-07-26 00:18:32 +0300
commit5423e908c9f5f12f599f6c9625ac9539be671695 (patch)
tree607c12985353a594262989deae9158cb45bcde34 /libavformat/httpauth.c
parentabf77a247baa19357bbf41d6460d4f65a8ff07f2 (diff)
downloadffmpeg-5423e908c9f5f12f599f6c9625ac9539be671695.tar.gz
Support urlencoded http authentication credentials
It should be possible to specify usernames in http requests containing urlencoded characters. This patch adds support for decoding the auth strings. Signed-off-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/httpauth.c')
-rw-r--r--libavformat/httpauth.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libavformat/httpauth.c b/libavformat/httpauth.c
index c1cf019eda..4ec8ac2599 100644
--- a/libavformat/httpauth.c
+++ b/libavformat/httpauth.c
@@ -25,6 +25,7 @@
#include "internal.h"
#include "libavutil/random_seed.h"
#include "libavutil/md5.h"
+#include "urldecode.h"
#include "avformat.h"
#include <ctype.h>
@@ -251,18 +252,28 @@ char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth,
return NULL;
if (state->auth_type == HTTP_AUTH_BASIC) {
- int auth_b64_len = AV_BASE64_SIZE(strlen(auth));
- int len = auth_b64_len + 30;
- char *ptr;
+ int auth_b64_len, len;
+ char *ptr, *decoded_auth = ff_urldecode(auth);
+
+ if (!decoded_auth)
+ return NULL;
+
+ auth_b64_len = AV_BASE64_SIZE(strlen(decoded_auth));
+ len = auth_b64_len + 30;
+
authstr = av_malloc(len);
- if (!authstr)
+ if (!authstr) {
+ av_free(decoded_auth);
return NULL;
+ }
+
snprintf(authstr, len, "Authorization: Basic ");
ptr = authstr + strlen(authstr);
- av_base64_encode(ptr, auth_b64_len, auth, strlen(auth));
+ av_base64_encode(ptr, auth_b64_len, decoded_auth, strlen(decoded_auth));
av_strlcat(ptr, "\r\n", len - (ptr - authstr));
+ av_free(decoded_auth);
} else if (state->auth_type == HTTP_AUTH_DIGEST) {
- char *username = av_strdup(auth), *password;
+ char *username = ff_urldecode(auth), *password;
if (!username)
return NULL;