From: Duncan Salerno <[email protected]>
Strip off query parameters from the original url before
applying the new relative path.
---
libavformat/url-test.c | 1 +
libavformat/utils.c | 8 +++++++-
tests/ref/fate/url | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libavformat/url-test.c b/libavformat/url-test.c
index 74b3225..aa07ffa 100644
--- a/libavformat/url-test.c
+++ b/libavformat/url-test.c
@@ -51,5 +51,6 @@ int main(int argc, char **argv)
test("http://server/foo/bar/123", "../../baz");
test("http://server/foo/bar/123", "/baz");
test("http://server/foo/bar/123", "https://other/url");
+ test("http://server/foo/bar?param=value/with/slashes", "/baz");
return 0;
}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b932322..2b20f65 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3389,7 +3389,7 @@ int ff_find_stream_index(AVFormatContext *s, int id)
void ff_make_absolute_url(char *buf, int size, const char *base,
const char *rel)
{
- char *sep;
+ char *sep, *path_query;
/* Absolute path, relative to the current server */
if (base && strstr(base, "://") && rel[0] == '/') {
if (base != buf)
@@ -3411,6 +3411,12 @@ void ff_make_absolute_url(char *buf, int size, const
char *base,
}
if (base != buf)
av_strlcpy(buf, base, size);
+
+ /* Strip off any query string from base */
+ path_query = strchr(buf, '?');
+ if (path_query != NULL)
+ *path_query = '\0';
+
/* Remove the file name from the base url */
sep = strrchr(buf, '/');
if (sep)
diff --git a/tests/ref/fate/url b/tests/ref/fate/url
index 801e8a3..bf85a97 100644
--- a/tests/ref/fate/url
+++ b/tests/ref/fate/url
@@ -8,3 +8,4 @@ http://server/baz
http://server/baz
http://server/baz
https://other/url
+http://server/baz
--
1.7.9.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel