[vlc-commits] httplive: handle better relative urls
Ilkka Ollakka
git at videolan.org
Wed Mar 20 07:50:04 CET 2013
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Wed Mar 20 08:41:50 2013 +0200| [1abf871cee239bff24d2e25c77f2c43d3a5cd741] | committer: Ilkka Ollakka
httplive: handle better relative urls
if path starts with / it's related to root of server and not
current path.
Fixes: #8321
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1abf871cee239bff24d2e25c77f2c43d3a5cd741
---
modules/stream_filter/httplive.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 1e39733..4771f79 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -547,10 +547,18 @@ static char *relative_URI(const char *psz_url, const char *psz_path)
if (strncmp(psz_path, "http", 4) == 0)
return NULL;
- char *path_end = strrchr(psz_url, '/');
- if (path_end == NULL)
+ char *path_separator=NULL;
+ if( psz_path[0] == '/' ) //Relative URL with absolute path
+ {
+ //Try to find separator for name and path, try to skip
+ //access and first ://
+ path_separator = strchr( &psz_url[8], '/');
+ } else {
+ path_separator = strrchr(psz_url, '/');
+ }
+ if ( unlikely( path_separator == NULL ) )
return NULL;
- unsigned int url_length = path_end - psz_url + 1;
+ const size_t url_length = path_separator - psz_url + 1;
char *psz_res = malloc(url_length + strlen(psz_path) + 1);
strncpy(psz_res, psz_url, url_length);
psz_res[url_length] = 0;
More information about the vlc-commits
mailing list