SoupURI: an empty query is distinct from no query
authorDan Winship <danw@gnome.org>
Mon, 7 Sep 2009 22:25:15 +0000 (18:25 -0400)
committerDan Winship <danw@gnome.org>
Mon, 7 Sep 2009 22:25:15 +0000 (18:25 -0400)
http://bugzilla.gnome.org/show_bug.cgi?id=594405

libsoup/soup-uri.c
tests/uri-parsing.c

index 5552f63..4f8610b 100644 (file)
@@ -247,14 +247,12 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
        /* Find query */
        question = memchr (uri_string, '?', end - uri_string);
        if (question) {
-               if (question[1]) {
-                       uri->query = uri_normalized_copy (question + 1,
-                                                         end - (question + 1),
-                                                         NULL, TRUE);
-                       if (!uri->query) {
-                               soup_uri_free (uri);
-                               return NULL;
-                       }
+               uri->query = uri_normalized_copy (question + 1,
+                                                 end - (question + 1),
+                                                 NULL, TRUE);
+               if (!uri->query) {
+                       soup_uri_free (uri);
+                       return NULL;
                }
                end = question;
        }
index 407ddfd..c2e4b58 100644 (file)
@@ -61,7 +61,11 @@ static struct {
 
        /* Try to recover certain kinds of invalid URIs */
        { "http://host/path with spaces",
-         "http://host/path%20with%20spaces" }
+         "http://host/path%20with%20spaces" },
+
+       /* Bug 594405; 0-length is different from not-present */
+       { "http://host/path?", "http://host/path?" },
+       { "http://host/path#", "http://host/path#" }
 };
 static int num_abs_tests = G_N_ELEMENTS(abs_tests);