[evolution-patches] soup patch for 61049
- From: Dan Winship <danw novell com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] soup patch for 61049
- Date: Tue, 06 Jul 2004 16:14:55 -0400
This makes soup_uri_new reject http URIs that don't have hostnames in
them, since I'm sure the same bug probably exists in other places in
connector and e-d-s besides the one reported in 61049.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libsoup/ChangeLog,v
retrieving revision 1.431
diff -u -r1.431 ChangeLog
--- ChangeLog 3 Jun 2004 13:53:05 -0000 1.431
+++ ChangeLog 6 Jul 2004 19:56:29 -0000
@@ -1,3 +1,10 @@
+2004-07-06 Dan Winship <danw novell com>
+
+ * libsoup/soup-uri.c (soup_uri_new_with_base): if the protocol is
+ http or https, require a hostname. For #61049
+
+ * tests/uri-parsing.c (rel_tests, do_uri): Update for that
+
2004-06-03 JP Rosevear <jpr novell com>
* configure.in: bump version to 2.1.11, libtool number
Index: libsoup/soup-uri.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-uri.c,v
retrieving revision 1.28
diff -u -r1.28 soup-uri.c
--- libsoup/soup-uri.c 18 Nov 2003 20:00:08 -0000 1.28
+++ libsoup/soup-uri.c 6 Jul 2004 19:56:29 -0000
@@ -216,6 +216,13 @@
}
}
+ /* Sanity check */
+ if ((uri->protocol == SOUP_PROTOCOL_HTTP ||
+ uri->protocol == SOUP_PROTOCOL_HTTPS) && !uri->host) {
+ soup_uri_free (uri);
+ return NULL;
+ }
+
if (!uri->port)
uri->port = soup_protocol_default_port (uri->protocol);
if (!uri->path)
Index: tests/uri-parsing.c
===================================================================
RCS file: /cvs/gnome/libsoup/tests/uri-parsing.c,v
retrieving revision 1.3
diff -u -r1.3 uri-parsing.c
--- tests/uri-parsing.c 27 Aug 2003 13:13:30 -0000 1.3
+++ tests/uri-parsing.c 6 Jul 2004 19:56:29 -0000
@@ -69,7 +69,14 @@
{ "g?y/../x", "http://a/b/c/g?y/../x" },
{ "g#s/./x", "http://a/b/c/g#s/./x" },
{ "g#s/../x", "http://a/b/c/g#s/../x" },
- { "http:g", "http:g" }
+
+ /* RFC 2396 notes that some old parsers will parse this as
+ * a relative URL ("http://a/b/c/g"), but it should be
+ * interpreted as absolute. libsoup should parse it
+ * correctly as being absolute, but then reject it since it's
+ * an http URL with no host.
+ */
+ { "http:g", NULL }
};
int num_rel_tests = G_N_ELEMENTS(rel_tests);
@@ -81,20 +88,32 @@
char *uri_string;
if (base_uri) {
- printf ("<%s> + <%s> = <%s>? ", base_str, in_uri, out_uri);
+ printf ("<%s> + <%s> = <%s>? ", base_str, in_uri,
+ out_uri ? out_uri : "ERR");
uri = soup_uri_new_with_base (base_uri, in_uri);
} else {
- printf ("<%s> => <%s>? ", in_uri, out_uri);
+ printf ("<%s> => <%s>? ", in_uri,
+ out_uri ? out_uri : "ERR");
uri = soup_uri_new (in_uri);
}
if (!uri) {
- printf ("ERR\n Could not parse %s\n", in_uri);
- return FALSE;
+ if (out_uri) {
+ printf ("ERR\n Could not parse %s\n", in_uri);
+ return FALSE;
+ } else {
+ printf ("OK\n");
+ return TRUE;
+ }
}
uri_string = soup_uri_to_string (uri, FALSE);
soup_uri_free (uri);
+
+ if (!out_uri) {
+ printf ("ERR\n Got %s\n", uri_string);
+ return FALSE;
+ }
if (strcmp (uri_string, out_uri) != 0) {
printf ("NO\n Unparses to <%s>\n", uri_string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]