nautilus r13695 - in trunk: . libnautilus-private



Author: alexl
Date: Tue Feb  5 11:42:48 2008
New Revision: 13695
URL: http://svn.gnome.org/viewvc/nautilus?rev=13695&view=rev

Log:
2008-02-05  Alexander Larsson  <alexl redhat com>

	* libnautilus-private/nautilus-file-operations.c (custom_basename_to_string):
	Escape characters that won't work in GMarkup.



Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-file-operations.c

Modified: trunk/libnautilus-private/nautilus-file-operations.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file-operations.c	(original)
+++ trunk/libnautilus-private/nautilus-file-operations.c	Tue Feb  5 11:42:48 2008
@@ -582,6 +582,28 @@
 	return result;
 }
 
+static gboolean
+has_invalid_xml_char (char *str)
+{
+	gunichar c;
+
+	while (*str != 0) {
+		c = g_utf8_get_char (str);
+		/* characters XML permits */
+		if (!(c == 0x9 ||
+		      c == 0xA ||
+		      c == 0xD ||
+		      (c >= 0x20 && c <= 0xD7FF) ||
+		      (c >= 0xE000 && c <= 0xFFFD) ||
+		      (c >= 0x10000 && c <= 0x10FFFF))) {
+			return TRUE;
+		}
+		str = g_utf8_next_char (str);
+	}
+	return FALSE;
+}
+
+
 static char *
 custom_full_name_to_string (char *format, va_list va)
 {
@@ -603,7 +625,7 @@
 {
 	GFile *file;
 	GFileInfo *info;
-	char *name, *basename;
+	char *name, *basename, *tmp;
 
 	file = va_arg (va, GFile *);
 
@@ -628,6 +650,13 @@
 			g_free (basename);
 		}
 	}
+
+	/* Some chars can't be put in the markup we use for the dialogs... */
+	if (has_invalid_xml_char (name)) {
+		tmp = name;
+		name = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
+		g_free (tmp);
+	}
 	
 	return name;
 }



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