|
18 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | 19 | */ |
20 | 20 |
|
| 21 | +#include "config.h" |
21 | 22 | #include "libavformat/url.h" |
22 | 23 | #include "libavformat/avformat.h" |
23 | 24 |
|
@@ -48,19 +49,30 @@ static void test_decompose(const char *url) |
48 | 49 |
|
49 | 50 | static void test(const char *base, const char *rel) |
50 | 51 | { |
51 | | - char buf[200], buf2[200]; |
| 52 | + char buf[200], buf2[200], buf_dos[200], buf_native[200]; |
52 | 53 | int ret; |
53 | 54 |
|
54 | | - ret = ff_make_absolute_url(buf, sizeof(buf), base, rel); |
| 55 | + ret = ff_make_absolute_url2(buf, sizeof(buf), base, rel, 0); |
55 | 56 | if (ret < 0) { |
56 | 57 | printf("%50s %-20s => error %s\n", base, rel, av_err2str(ret)); |
57 | 58 | return; |
58 | 59 | } |
59 | 60 | printf("%50s %-20s => %s\n", base, rel, buf); |
| 61 | + ret = ff_make_absolute_url2(buf_dos, sizeof(buf_dos), base, rel, 1); |
| 62 | + if (ret < 0) |
| 63 | + snprintf(buf_dos, sizeof(buf_dos), "error %s", av_err2str(ret)); |
| 64 | + ret = ff_make_absolute_url(buf_native, sizeof(buf_native), base, rel); |
| 65 | + if (ret < 0) |
| 66 | + snprintf(buf_native, sizeof(buf_native), "error %s", av_err2str(ret)); |
| 67 | + if (strcmp(buf, buf_dos)) |
| 68 | + printf("%50s %-20sDOS %s\n", base, rel, buf_dos); |
| 69 | + if (HAVE_DOS_PATHS && strcmp(buf_dos, buf_native) || |
| 70 | + !HAVE_DOS_PATHS && strcmp(buf, buf_native)) |
| 71 | + printf("Native mismatch\n"); |
60 | 72 | if (base) { |
61 | 73 | /* Test in-buffer replacement */ |
62 | 74 | snprintf(buf2, sizeof(buf2), "%s", base); |
63 | | - ff_make_absolute_url(buf2, sizeof(buf2), buf2, rel); |
| 75 | + ff_make_absolute_url2(buf2, sizeof(buf2), buf2, rel, 0); |
64 | 76 | if (strcmp(buf, buf2)) { |
65 | 77 | printf("In-place handling of %s + %s failed\n", base, rel); |
66 | 78 | exit(1); |
@@ -121,6 +133,21 @@ int main(void) |
121 | 133 | test("http://server/foo/bar", "..doubledotfile"); |
122 | 134 | test("http://server/foo/bar", "double..dotfile"); |
123 | 135 | test("http://server/foo/bar", "doubledotfile.."); |
| 136 | + test("file1", "file2"); |
| 137 | + test("dir/file1", "file2"); |
| 138 | + test("dir/file1", "../file2"); |
| 139 | + test("dir\\file1", "file2"); |
| 140 | + test("\\\\srv\\shr\\file", "..\\..\\dummy"); |
| 141 | + test("\\\\srv\\shr\\file", "dummy"); |
| 142 | + test("\\\\srv\\shr\\file", "\\\\srv2\\shr2\\file2"); |
| 143 | + test("\\\\srv\\shr\\file", "d:/file"); |
| 144 | + test("C:\\dir\\a", "..\\file"); |
| 145 | + test("C:\\dir\\a", "\\\\srv\\shr\\file"); |
| 146 | + test("C:\\dir\\a", "d:\\file"); |
| 147 | + test("http://a/b", "\\\\srv\\shr\\file"); |
| 148 | + test("http://a/b", "//srv/shr/file"); |
| 149 | + test("http://a/b", "d:\\file"); |
| 150 | + test("http://a/b", "C:/file"); |
124 | 151 |
|
125 | 152 | /* From https://tools.ietf.org/html/rfc3986#section-5.4 */ |
126 | 153 | test("http://a/b/c/d;p?q", "g:h"); // g:h |
|
0 commit comments