[PATCH] Make gnome_vfs_make_uri_from_input_internal more robust



The attached patch is meant to "fix" bug 329781 [1] by making
gnome_vfs_make_uri_from_input_internal a bit more robst. I don't like
the route we currently go, i.e. we just guess based on the string
instead of using GnomeVFSURIs, but it's probably too late in the cycle
to change that. The function might need some more love and URI sanity
checking, but the attached patch did the trick for me.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=329781

-- 
Christian Neumair <chris gnome-de org>
Index: libgnomevfs/gnome-vfs-utils.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-utils.c,v
retrieving revision 1.106
diff -u -p -r1.106 gnome-vfs-utils.c
--- libgnomevfs/gnome-vfs-utils.c	20 Dec 2005 09:44:43 -0000	1.106
+++ libgnomevfs/gnome-vfs-utils.c	24 Feb 2006 16:21:44 -0000
@@ -1337,11 +1337,17 @@ looks_like_http_uri (const char *str)
 	int i;
 	char c;
 	const char *first_slash;
+	const char *first_dot;
 
 	first_slash = strchr(str, '/');
 	if (first_slash == NULL) {
 		len = strlen (str);
 	} else {
+		first_dot = strchr (str, '.');
+		if (first_dot != NULL && first_slash < first_dot) {
+			return FALSE;
+		}
+
 		len = first_slash - str;
 	}
 	for (i = 0; i < 5 && i < len; i++) {
@@ -1366,7 +1372,7 @@ gnome_vfs_make_uri_from_input_internal (
 					const char *filename_charset,
 					gboolean strip_trailing_whitespace)
 {
-	char *stripped, *uri, *locale_path, *escaped;
+	char *stripped, *uri, *locale_path, *escaped, *p;
 
 	g_return_val_if_fail (text != NULL, g_strdup (""));
 
@@ -1428,8 +1434,10 @@ gnome_vfs_make_uri_from_input_internal (
 			uri = g_strconcat ("http://";, escaped, NULL);
 			g_free (escaped);
 		} else {
-			escaped = gnome_vfs_escape_high_chars ((guchar *)stripped);
-			uri = g_strconcat ("file://", escaped, NULL);
+			for (p = stripped; p != NULL && *p == '/'; p++)
+				;
+			escaped = gnome_vfs_escape_high_chars ((guchar *)p);
+			uri = g_strconcat ("file:///", escaped, NULL);
 			g_free (escaped);
 		}
 	}

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



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