Re: Found cause of 46582, what to do?



On Sat, 2002-05-04 at 15:08, Darin Adler wrote:
> 
> On Saturday, May 4, 2002, at 11:59 AM, David Emory Watson wrote:
> 
> >> files with a URL using %20 characters or by double-clicking on them.
> >
> > The user should *definitely* not have to type in an escaped string.
> 
> There are *many* filenames that you can only type in as escaped strings. Any filenames with control characters in them in the %01 to %1F range, and filenames with characters in the %80 or higher range that are not part of valid UTF-8 sequences. We don't support the kinds of escaping syntax that is used in the shell for such file names -- instead we fall back on URL syntax.

Well, that sucks. :)

> The tradeoff is simply which of these two features is more important:
>
>      1) Making filenames with trailing spaces fall into the category where you can type the filename without having to fall back on URL syntax.

While this is an unrelated bug, you currently cannot type "file%20name"
to goto "file name".

>      2) Repairing the common mistake of copying an extra space when copying a filename from another window, say a terminal, for the vast majority of files that don't have trailing spaces in their names.

The attached patch preserves both features and makes auto-completion a
little nicer.  Comments in the code explain it all...
 
> I couldn't care less about either feature :-)

Yeah, I suppose it is fairly minor annoyance.  Sorry for making you
think about it for so long today.  On the bright side,
sizeof_bugzilla--;
? autocompletion-eel-patch
? test/test-eel-pixbuf-scale
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.372
diff -p -u -r1.372 ChangeLog
--- ChangeLog	30 Apr 2002 23:51:00 -0000	1.372
+++ ChangeLog	4 May 2002 21:30:01 -0000
@@ -1,3 +1,13 @@
+2002-05-04  David Emory Watson  <dwatson cs ucr edu>
+
+	* eel/eel-vfs-extensions.c:
+	* eel/eel-vfs-extensions.h:
+	(eel_make_uri_from_input_internal): Optionally strip trailing
+	whitespace since it could be part of a valid uri.
+	(eel_make_uri_from_input): Update.
+	(eel_make_uri_from_input_but_preserve_trailing_whitespace): New.
+	Needed to fix bug 46582.
+
 2002-04-30  Alexander Larsson  <alla lysator liu se>
 
 	* eel/eel-preferences-item.c
Index: eel/eel-vfs-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-vfs-extensions.c,v
retrieving revision 1.7
diff -p -u -r1.7 eel-vfs-extensions.c
--- eel/eel-vfs-extensions.c	18 Mar 2002 04:24:50 -0000	1.7
+++ eel/eel-vfs-extensions.c	4 May 2002 21:30:01 -0000
@@ -731,17 +731,29 @@ eel_escape_high_chars (const guchar *str
 	return result;
 }
 
+
+/* The strip_trailing_whitespace option is intended to make copy/paste of
+ * URIs less error-prone when it is known that trailing whitespace isn't
+ * part of the uri.
+ */
 static char *
-eel_make_uri_from_input_internal (const char *text, gboolean filenames_are_locale_encoded)
+eel_make_uri_from_input_internal (const char *text,
+				  gboolean filenames_are_locale_encoded,
+				  gboolean strip_trailing_whitespace)
 {
 	char *stripped, *path, *uri, *locale_path, *filesystem_path, *escaped;
 
 	g_return_val_if_fail (text != NULL, g_strdup (""));
 
-	/* Strip off leading and trailing spaces.
-	 * This makes copy/paste of URIs less error-prone.
+	/* Strip off leading whitespaces (since they can't be part of a valid
+	   uri).   Only strip off trailing whitespaces when requested since
+	   they might be part of a valid uri.
 	 */
-	stripped = g_strstrip (g_strdup (text));
+	if (strip_trailing_whitespace) {
+		stripped = g_strstrip (g_strdup (text));
+	} else {
+		stripped = g_strchug (g_strdup (text));
+	}
 
 	switch (stripped[0]) {
 	case '\0':
@@ -866,10 +878,20 @@ char *
 eel_make_uri_from_input (const char *location)
 {
 	static gboolean broken_filenames;
-	
+
+	broken_filenames = g_getenv ("G_BROKEN_FILENAMES") != NULL;
+
+	return eel_make_uri_from_input_internal (location, broken_filenames, TRUE);
+}
+
+char *
+eel_make_uri_from_input_with_trailing_ws (const char *location)
+{
+	static gboolean broken_filenames;
+
 	broken_filenames = g_getenv ("G_BROKEN_FILENAMES") != NULL;
 
-	return eel_make_uri_from_input_internal (location, broken_filenames);
+	return eel_make_uri_from_input_internal (location, broken_filenames, FALSE);
 }
 
 /* Note that NULL's and full paths are also handled by this function.
@@ -1584,19 +1606,19 @@ eel_self_check_vfs_extensions (void)
 
 
 	/* not G_BROKEN_FILENAMES: */
-	EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/\303\245\303\244\303\266", 0), "file:///%E6%97%A5%E6%9C%AC%E8%AA%9E/%C3%A5%C3%A4%C3%B6");
-	EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("http://www.google.com/\346\227\245\346\234\254\350\252\236/\303\245\303\244\303\266";, 0), "http://www.google.com/%E6%97%A5%E6%9C%AC%E8%AA%9E/%C3%A5%C3%A4%C3%B6";);
+	EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/\303\245\303\244\303\266", 0, TRUE), "file:///%E6%97%A5%E6%9C%AC%E8%AA%9E/%C3%A5%C3%A4%C3%B6");
+	EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("http://www.google.com/\346\227\245\346\234\254\350\252\236/\303\245\303\244\303\266";, 0, TRUE), "http://www.google.com/%E6%97%A5%E6%9C%AC%E8%AA%9E/%C3%A5%C3%A4%C3%B6";);
 
 	/* G_BROKEN_FILENAMES: */
 	/* This is somewhat broken, but we can't set the locale */
 	g_get_charset (&charset);
 	if (strcasecmp (charset, "ISO-8859-1") == 0) {
-		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\303\245\303\244\303\266/test", 1), "file:///%E5%E4%F6/test");
-		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/test", 1), "");
+		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\303\245\303\244\303\266/test", 1, TRUE), "file:///%E5%E4%F6/test");
+		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/test", 1, TRUE), "");
 	}
 	if (strcasecmp (charset, "EUC-JP") == 0) {
-		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/test", 1), "file:///%C6%FC%CB%DC%B8%EC/test");
-		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\303\245\303\244\303\266/test", 1), "file:///%8F%AB%A9%8F%AB%A3%8F%AB%D3/test");
+		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\346\227\245\346\234\254\350\252\236/test", 1, TRUE), "file:///%C6%FC%CB%DC%B8%EC/test");
+		EEL_CHECK_STRING_RESULT (eel_make_uri_from_input_internal ("/\303\245\303\244\303\266/test", 1, TRUE), "file:///%8F%AB%A9%8F%AB%A3%8F%AB%D3/test");
 	}
 
 	EEL_CHECK_STRING_RESULT (eel_uri_get_scheme ("file:///var/tmp"), "file");
Index: eel/eel-vfs-extensions.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-vfs-extensions.h,v
retrieving revision 1.5
diff -p -u -r1.5 eel-vfs-extensions.h
--- eel/eel-vfs-extensions.h	19 Oct 2001 23:17:33 -0000	1.5
+++ eel/eel-vfs-extensions.h	4 May 2002 21:30:01 -0000
@@ -67,6 +67,7 @@ gboolean           eel_uri_is_in_trash  
 
 char *             eel_format_uri_for_display            (const char           *uri);
 char *             eel_make_uri_from_input               (const char           *location);
+char *             eel_make_uri_from_input_with_trailing_ws (const char        *location);
 char *             eel_make_uri_from_shell_arg           (const char           *location);
 char *             eel_make_uri_canonical                (const char           *uri);
 char *             eel_make_uri_canonical_strip_fragment (const char           *uri);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5264
diff -p -u -r1.5264 ChangeLog
--- ChangeLog	4 May 2002 14:55:46 -0000	1.5264
+++ ChangeLog	4 May 2002 21:29:11 -0000
@@ -1,3 +1,10 @@
+2002-05-04  David Emory Watson  <dwatson cs ucr edu>
+
+	* src/nautilus-location-bar.c:
+	(try_to_expand_path): Handle filenames with embeded or trailing white-
+	space.  Fixes bug 46582.  Also fixes a minor utf8 bug that crept into
+	the build.
+
 2002-05-03  David Emory Watson  <dwatson cs ucr edu>
 
 	* src/nautilus-location-bar.c:
Index: src/nautilus-location-bar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-location-bar.c,v
retrieving revision 1.85
diff -p -u -r1.85 nautilus-location-bar.c
--- src/nautilus-location-bar.c	4 May 2002 14:55:48 -0000	1.85
+++ src/nautilus-location-bar.c	4 May 2002 21:29:12 -0000
@@ -383,7 +383,9 @@ try_to_expand_path (gpointer callback_da
 		return FALSE;
 	}
 
-	current_path = eel_make_uri_from_input (user_location);
+	/* Trailing whitespace is OK here since the cursor is known to
+	   be at the end of the text and therefor after the whitespace. */
+	current_path = eel_make_uri_from_input_with_trailing_ws (user_location);
 	if (!eel_istr_has_prefix (current_path, "file://")) {
 		g_free (user_location);
 		g_free (current_path);
@@ -465,7 +467,7 @@ try_to_expand_path (gpointer callback_da
 			pos = user_location_length;
 			gtk_editable_insert_text (editable,
 						  insert_text,
-						  strlen (insert_text),
+						  g_utf8_strlen (insert_text, -1),
 						  &pos);
 
 			pos = user_location_length;


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