Index: src/ncb-rename-dialog.c
===================================================================
--- src/ncb-rename-dialog.c	(revisione 2272)
+++ src/ncb-rename-dialog.c	(copia locale)
@@ -43,6 +43,8 @@
 
 #define NCB_RENAME_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NCB_TYPE_RENAME_DIALOG, NcbRenameDialogPrivate))
 
+#define JOLIET_NAME_MAX 64
+
 struct NcbRenameDialogInvalidFile {
 	char	*mime_type;
 	char	*filename;
@@ -549,12 +551,36 @@
 static char *
 make_valid_filename (const char *name)
 {
+	GString		*truncated	 = NULL;
 	GString		*string;
 	const char	*remainder;
 	const char	*invalid;
 	int		 remaining_bytes;
 	int		 valid_bytes;
 
+	/* Truncate the filename to JOLIET_NAME_MAX characters, possibly preserving its extension */
+	if (g_utf8_strlen (name, -1) > JOLIET_NAME_MAX) {
+		char	*last_dot;
+		int	 ext_len = 0;
+		
+		last_dot = g_utf8_strrchr (name, -1, '.');
+		if (last_dot) {
+			ext_len = g_utf8_strlen (last_dot, -1);
+		}
+
+		truncated = g_string_sized_new (JOLIET_NAME_MAX * 4);
+		g_utf8_strncpy (truncated->str,
+				name,
+				JOLIET_NAME_MAX - ext_len);
+		truncated->len = JOLIET_NAME_MAX - ext_len;
+
+		if (last_dot) {
+			g_string_append (truncated, last_dot);
+		}
+
+		name = truncated->str;
+	}
+
 	string = NULL;
 	remainder = name;
 	remaining_bytes = strlen (name);
@@ -579,10 +605,17 @@
 		remainder = invalid + 1;
 	}
 
+	
+
 	if (string == NULL) {
-		return g_strdup (name);
+		return (truncated) ? g_string_free (truncated, FALSE)
+				   : g_strdup (name);
 	}
 
+	if (truncated) {
+		g_string_free (truncated, TRUE);
+	}
+
 	string = g_string_append (string, remainder);
 	g_assert (g_utf8_validate (string->str, -1, NULL));
 
@@ -698,8 +731,10 @@
 			NcbRenameDialog   *dialog,
 			gboolean          *recurse)
 {
+	const char *name = g_file_info_get_name (info);
 
-	if (! g_utf8_validate (g_file_info_get_name (info), -1, NULL)) {
+	if (! g_utf8_validate (name, -1, NULL)
+	    || g_utf8_strlen (name, -1) > JOLIET_NAME_MAX) {
 		NcbRenameDialogInvalidFile *invalid_file;
 
 		invalid_file = g_new0 (NcbRenameDialogInvalidFile, 1);
