[evolution-data-server/meego-eds] Fix a crash if the folder name isnt in English.



commit 17c0453c6cbf72dd49f798cdbeb06a960abcb86a
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Tue Jul 26 12:30:45 2011 +0530

    Fix a crash if the folder name isnt in English.

 mail/daemon/e-mail-data-store.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/mail/daemon/e-mail-data-store.c b/mail/daemon/e-mail-data-store.c
index 70c9a17..9891fef 100644
--- a/mail/daemon/e-mail-data-store.c
+++ b/mail/daemon/e-mail-data-store.c
@@ -86,14 +86,38 @@ e_mail_data_store_class_init (EMailDataStoreClass *klass)
   object_class->finalize = e_mail_data_store_finalize;
 }
 
+static gboolean
+check_if_ascii (const char *name)
+{
+	int i=0, len;
+
+	len = strlen (name);
+
+	for (i=0; i< len; i++) {
+		if (!g_ascii_isalnum(name[i]))
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
 static gchar *
 construct_mail_store_path (char *full_name)
 {
 	static volatile gint counter = 1;
 	int i, len;
-	char *path = g_strdup_printf (
+	char *path;
+	gsize read=0, written=0;
+	char *name;
+
+	if (check_if_ascii(full_name))
+		name = g_strdup(full_name);
+	else
+		name = g_strdup_printf ("%lu_%d", time(NULL), g_atomic_int_exchange_and_add (&counter, 1));
+	
+	path = g_strdup_printf (
 		       "/org/gnome/evolution/dataserver/mail/folder/%s/%d/%u",
-		       full_name, getpid (), g_atomic_int_exchange_and_add (&counter, 1));
+		       name, getpid (), g_atomic_int_exchange_and_add (&counter, 1));
 	len = strlen(path);
 	for (i=0; i<len ; i++)
 		if (path[i] == '.')



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