From: Duncan Salerno <[email protected]>
This is defined by RFC 3986 section 5.4.1 to be handled this way.
---
libavformat/url-test.c | 1 +
libavformat/utils.c | 14 ++++++++++----
tests/ref/fate/url | 1 +
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/libavformat/url-test.c b/libavformat/url-test.c
index 5c0bccb..cc56291 100644
--- a/libavformat/url-test.c
+++ b/libavformat/url-test.c
@@ -53,5 +53,6 @@ int main(int argc, char **argv)
test("http://server/foo/bar/123", "https://other/url");
test("http://server/foo/bar?param=value/with/slashes", "/baz");
test("http://server/foo/bar?param&otherparam", "?someparam");
+ test("http://server/foo/bar", "//other/url");
return 0;
}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6833de4..0878096 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3396,10 +3396,16 @@ void ff_make_absolute_url(char *buf, int size, const
char *base,
av_strlcpy(buf, base, size);
sep = strstr(buf, "://");
if (sep) {
- sep += 3;
- sep = strchr(sep, '/');
- if (sep)
- *sep = '\0';
+ /* Take scheme from base url */
+ if (rel[1] == '/') {
+ sep[1] = '\0';
+ } else {
+ /* Take scheme and host from base url */
+ sep += 3;
+ sep = strchr(sep, '/');
+ if (sep)
+ *sep = '\0';
+ }
}
av_strlcat(buf, rel, size);
return;
diff --git a/tests/ref/fate/url b/tests/ref/fate/url
index b1e91fb..1a6051e 100644
--- a/tests/ref/fate/url
+++ b/tests/ref/fate/url
@@ -10,3 +10,4 @@ http://server/baz
https://other/url
http://server/baz
http://server/foo/bar?someparam
+http://other/url
--
1.7.9.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel