url: Handle relative urls starting with two slashes
authorDuncan Salerno <duncan.salerno@gmail.com>
Fri, 5 Oct 2012 23:02:18 +0000 (02:02 +0300)
committerMartin Storsjö <martin@martin.st>
Tue, 9 Oct 2012 11:16:33 +0000 (14:16 +0300)
This is defined by RFC 3986 section 5.4.1 to be handled this way.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/utils.c

index 9d0049a9adb566e3503bca63298d7babb9f9fee4..ca52469bdb0355f9db22bb2389e3b7895825423a 100644 (file)
@@ -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;