diff options
author | Ryan Gonzalez <rymg19@gmail.com> | 2021-03-07 15:47:21 -0600 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2021-03-08 16:24:44 +0000 |
commit | f33439899b0739a10de47baf50552d1c7eb58d77 (patch) | |
tree | 52289bc1d5d15cacd714121d0fd06b4e6b273431 | |
parent | f9061aada1b6eff651843e830406d1d8af1bd9bb (diff) | |
download | libsoup-f33439899b0739a10de47baf50552d1c7eb58d77.tar.gz |
soup-uri: Don't attempt to resolve relative paths in data URLs
RFC2397 states that data URLs have "no relative URL forms", but
soup_uri_new_with_base would still attempt to resolve any suspected
relative URL paths regardless. This was also inconsistent with the
behavior of most web browsers.
-rw-r--r-- | libsoup/soup-uri.c | 5 | ||||
-rw-r--r-- | tests/uri-parsing-test.c | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c index 4bb55b81..bdb7a175 100644 --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -309,6 +309,11 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string) return uri; } + if (g_strcmp0 (uri->scheme, SOUP_URI_SCHEME_DATA) == 0) { + /* Data URIs are never relative */ + remove_dot_segments = FALSE; + } + /* Check for authority */ if (strncmp (uri_string, "//", 2) == 0) { uri_string += 2; diff --git a/tests/uri-parsing-test.c b/tests/uri-parsing-test.c index d463f1f4..07ef96b2 100644 --- a/tests/uri-parsing-test.c +++ b/tests/uri-parsing-test.c @@ -525,7 +525,10 @@ static const DataURITest data_tests[] = { "" }, { "data:text/plain,", "text/plain", - "" } + "" }, + { "data:,a/../b", + "text/plain;charset=US-ASCII", + "a/../b" } }; static void |