[PATCH] Bug#153055 - user name in "Connect to Server" dialog box is not escaped



Attached is a patch which should properly escape the various components
of the uri generated by the "Connect to Server" dialog.

While I believe this patch fixes the issue from nautilus's perspective
there still does seem to be an issue in gnome-vfs in that while I will
properly extract the username from the uri string, it does not look like
it properly decodes it, before possibly re-encoding it again (tested
against an http source).

I will have to look at gnome-vfs more closely to determine if this is
indeed the problem, but figured I would throw the patch out there in the
meantime.

-- Michael
? connect-to-server.patch
? mkinstalldirs
Index: src/nautilus-connect-server-dialog.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-connect-server-dialog.c,v
retrieving revision 1.9
diff -p -u -r1.9 nautilus-connect-server-dialog.c
--- src/nautilus-connect-server-dialog.c	24 Aug 2004 13:30:02 -0000	1.9
+++ src/nautilus-connect-server-dialog.c	27 Sep 2004 03:53:36 -0000
@@ -28,6 +28,7 @@
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-vfs-extensions.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtktable.h>
 #include <gtk/gtklabel.h>
@@ -144,7 +145,8 @@ connect_to_server (NautilusConnectServer
 		}
 	} else {
 		char *method, *user, *port, *initial_path, *server, *folder;
-		char *t;
+		char *t, *join;
+		char **paths;
 		gboolean free_initial_path, free_user, free_port;
 
 		server = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1);
@@ -196,23 +198,57 @@ connect_to_server (NautilusConnectServer
 		folder = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->folder_entry), 0, -1);
 		if (dialog->details->user_entry->parent != NULL) {
 			free_user = TRUE;
-			user = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1);
+			
+			t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1);
+
+			user = gnome_vfs_escape_string (t);
+
+			g_free (t);
 		}
 
 		if (folder[0] != 0 &&
 		    folder[0] != '/') {
-			t = folder;
-			folder = g_strconcat ("/", t, NULL);
-			g_free (t);
+			join = "/";
+		} else {
+			join = "";
 		}
+
+		t = folder;
+
+		folder = g_strconcat (initial_path, join, t, NULL);
+
+		g_free (t);
+
+		paths = g_strsplit (folder, "/", -1);
+
+		if (paths) {
+			gchar **tmp, *part;
+
+			for (tmp = paths; *tmp; tmp++ ) {
+				part = *tmp;
+
+				if( !strlen (part) )
+					continue;
+
+				*tmp = gnome_vfs_escape_string (part);
+
+				g_free (part);
+			}
+
+			g_free (folder);
 		
-		uri = g_strdup_printf ("%s://%s%s%s%s%s%s%s",
+			folder = g_strjoinv ( "/", paths);
+
+			g_strfreev (paths);
+		}
+
+		uri = g_strdup_printf ("%s://%s%s%s%s%s%s",
 				       method,
 				       user, (user[0] != 0) ? "@" : "",
 				       server,
 				       (port[0] != 0) ? ":" : "", port,
-				       initial_path,
 				       folder);
+
 		if (free_initial_path) {
 			g_free (initial_path);
 		}


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