[evolution-patches] seeking review for patch for bug 55102



Hi, there,

This bug will affect all platforms. If the mail account name contains
special characters like "#", user can't access that account.

The patch is coming from the code of shell folder name validation.
Please review it.

Thanks.
Calvin
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3142
diff -u -r1.3142 ChangeLog
--- mail/ChangeLog	3 Mar 2004 08:11:15 -0000	1.3142
+++ mail/ChangeLog	3 Mar 2004 09:01:38 -0000
@@ -1,3 +1,9 @@
+2004-03-03  Calvin Liu <calvin liu sun com>
+	* mail-account-gui.c
+	add mail_account_name_is_valid () and change mail_account_gui_save
+	to check if account name is valid before save it.
+	fixes bug 55102
+
 2004-03-03  Not Zed  <NotZed Ximian com>
 
 	** See bug #54924.

Index: mail/mail-account-gui.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-account-gui.c,v
retrieving revision 1.148
diff -u -r1.148 mail-account-gui.c
--- mail/mail-account-gui.c	24 Feb 2004 21:31:19 -0000	1.148
+++ mail/mail-account-gui.c	3 Mar 2004 08:58:01 -0000
@@ -1949,6 +1949,7 @@
 	const char *new_name;
 	gboolean is_storage;
 	GSList *signatures;
+	const char *reason = NULL;
 	
 	if (!mail_account_gui_identity_complete (gui, NULL) ||
 	    !mail_account_gui_source_complete (gui, NULL) ||
@@ -1963,6 +1964,12 @@
 	 * here. */
 	
 	new_name = gtk_entry_get_text (gui->account_name);
+        if (! mail_account_name_is_valid (new_name, &reason)){
+                e_notice (gui->account_name, GTK_MESSAGE_ERROR,
+                                  _("The specified account name is not valid: %s"), reason);
+                return FALSE;
+        }
+
 	account = mail_config_get_account_by_name (new_name);
 	
 	if (account && account != new) {
@@ -2092,3 +2099,43 @@
 	g_free (gui->sent_folder_uri);
 	g_free (gui);
 }
+
+gboolean
+mail_account_name_is_valid (const char *name,
+                              const char **reason_return)
+{
+        if (name == NULL || *name == '\0') {
+                if (reason_return != NULL)
+                        *reason_return = _("No account name specified.");
+                return FALSE;
+        }
+                                                                                                                                         
+        /* GtkEntry is broken - if you hit KP_ENTER you get a \r inserted... */
+        if (strchr (name, '\r')) {
+                if (reason_return != NULL)
+                        *reason_return = _("Account name cannot contain the Return character.");
+                return FALSE;
+        }
+                                                                                                                                         
+        if (strchr (name, '/') != NULL) {
+                if (reason_return != NULL)
+                        *reason_return = _("Account name cannot contain the character \"/\".");
+                return FALSE;
+        }
+                                                                                                                                         
+        if (strchr (name, '#') != NULL) {
+                if (reason_return != NULL)
+                        *reason_return = _("Account name cannot contain the character \"#\".");
+                return FALSE;
+        }
+                                                                                                                                         
+        if (strcmp (name, ".") == 0 || strcmp (name, "..") == 0) {
+                if (reason_return != NULL)
+                        *reason_return = _("Account name cannot contain the character \".\".");
+                return FALSE;
+        }
+                                                                                                                                         
+        *reason_return = NULL;
+                                                                                                                                         
+        return TRUE;
+}


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