aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorPetr Doubek <doubek@vision.ee.ethz.ch>2004-08-12 00:09:32 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-08-12 00:09:32 +0000
commit6ba5cbc699e77cae66bb719354fa142114b64eab (patch)
tree4d0862ca409f9db2ad6f121e66fc40275557dfa4 /libavformat/utils.c
parent1477ec35dd958bf2c1ec7b4221a3d571c5b61449 (diff)
downloadffmpeg-6ba5cbc699e77cae66bb719354fa142114b64eab.tar.gz
HTTP Authentication Patch by (Petr Doubek <doubek at vision dot ee dot ethz dot ch>)
tested and submitted by (Torsten Spindler <spindler at hbt dot arch dot ethz dot ch>) Originally committed as revision 3381 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index be3df4a6e7..94169adf92 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2499,6 +2499,7 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
}
void url_split(char *proto, int proto_size,
+ char *authorization, int authorization_size,
char *hostname, int hostname_size,
int *port_ptr,
char *path, int path_size,
@@ -2519,6 +2520,8 @@ void url_split(char *proto, int proto_size,
}
if (proto_size > 0)
*q = '\0';
+ if (authorization_size > 0)
+ authorization[0] = '\0';
if (*p == '\0') {
if (proto_size > 0)
proto[0] = '\0';
@@ -2526,15 +2529,32 @@ void url_split(char *proto, int proto_size,
hostname[0] = '\0';
p = url;
} else {
+ char *at,*slash; // PETR: position of '@' character and '/' character
+
p++;
if (*p == '/')
p++;
if (*p == '/')
p++;
- q = hostname;
- while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {
- if ((q - hostname) < hostname_size - 1)
+ at = strchr(p,'@'); // PETR: get the position of '@'
+ slash = strchr(p,'/'); // PETR: get position of '/' - end of hostname
+ if (at && slash && at > slash) at = NULL; // PETR: not interested in '@' behind '/'
+
+ q = at ? authorization : hostname; // PETR: if '@' exists starting with auth.
+
+ while ((at || *p != ':') && *p != '/' && *p != '?' && *p != '\0') { // PETR:
+ if (*p == '@') { // PETR: passed '@'
+ if (authorization_size > 0)
+ *q = '\0';
+ q = hostname;
+ at = NULL;
+ } else if (!at) { // PETR: hostname
+ if ((q - hostname) < hostname_size - 1)
+ *q++ = *p;
+ } else {
+ if ((q - authorization) < authorization_size - 1)
*q++ = *p;
+ }
p++;
}
if (hostname_size > 0)