[libsoup/gnome-3-38] soup-uri: Don't attempt to resolve relative paths in data URLs



commit f33439899b0739a10de47baf50552d1c7eb58d77
Author: Ryan Gonzalez <rymg19 gmail com>
Date:   Sun Mar 7 15:47:21 2021 -0600

    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.

 libsoup/soup-uri.c       | 5 +++++
 tests/uri-parsing-test.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
---
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]