aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-11-10 18:46:41 +0800
committerMilan Crha <mcrha@redhat.com>2009-11-10 18:46:41 +0800
commitb9953ceaed91acfcca24a54240ff51847526e6a8 (patch)
tree46b10672faa374ed0fb072e480d52a1032f2d2a0 /mail
parent5beeca1f80c3a618feeeb2c5b7e09cc47b64387d (diff)
downloadgsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.gz
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.zst
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.zip
Bug #250046 - Composer addresses reading fixes
- Check for no addresses properly (in post-to only when shown) - Check for garbage addresses and warn user about those - Use garbage text in To/CC/Bcc fields when user typed them
Diffstat (limited to 'mail')
-rw-r--r--mail/em-composer-utils.c75
-rw-r--r--mail/mail.error.xml18
2 files changed, 86 insertions, 7 deletions
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 32c30fdb60..44ad930405 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -279,6 +279,18 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag
g_free (send);
}
+static gboolean
+is_group_definition (const gchar *str)
+{
+ const gchar *colon;
+
+ if (!str || !*str)
+ return FALSE;
+
+ colon = strchr (str, ':');
+ return colon > str && strchr (str, ';') > colon;
+}
+
static CamelMimeMessage *
composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
{
@@ -292,10 +304,11 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
GConfClient *gconf;
EAccount *account;
gint i;
- GList *postlist;
EMEvent *eme;
EMEventTargetComposer *target;
EComposerHeaderTable *table;
+ EComposerHeader *post_to_header;
+ GString *invalid_addrs = NULL;
gconf = mail_config_get_gconf_client ();
table = e_msg_composer_get_header_table (composer);
@@ -315,8 +328,35 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
const gchar *addr = e_destination_get_address (recipients[i]);
if (addr && addr[0]) {
+ gint len, j;
+
camel_address_decode ((CamelAddress *) cia, addr);
- if (camel_address_length ((CamelAddress *) cia) > 0) {
+ len = camel_address_length ((CamelAddress *) cia);
+
+ if (len > 0) {
+ if (!e_destination_is_evolution_list (recipients[i])) {
+ for (j = 0; j < len; j++) {
+ const gchar *name = NULL, *eml = NULL;
+
+ if (!camel_internet_address_get (cia, j, &name, &eml) ||
+ !eml ||
+ strchr (eml, '@') <= eml) {
+ if (!invalid_addrs)
+ invalid_addrs = g_string_new ("");
+ else
+ g_string_append (invalid_addrs, ", ");
+
+ if (name)
+ g_string_append (invalid_addrs, name);
+ if (eml) {
+ g_string_append (invalid_addrs, name ? " <" : "");
+ g_string_append (invalid_addrs, eml);
+ g_string_append (invalid_addrs, name ? ">" : "");
+ }
+ }
+ }
+ }
+
camel_address_remove ((CamelAddress *) cia, -1);
num++;
if (e_destination_is_evolution_list (recipients[i])
@@ -325,6 +365,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
} else {
shown++;
}
+ } else if (is_group_definition (addr)) {
+ /* like an address, it will not claim on only-bcc */
+ shown++;
+ num++;
+ } else if (!invalid_addrs) {
+ invalid_addrs = g_string_new (addr);
+ } else {
+ g_string_append (invalid_addrs, ", ");
+ g_string_append (invalid_addrs, addr);
}
}
}
@@ -349,10 +398,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
camel_object_unref (cia);
- postlist = e_composer_header_table_get_post_to (table);
- num_post = g_list_length(postlist);
- g_list_foreach(postlist, (GFunc)g_free, NULL);
- g_list_free(postlist);
+ post_to_header = e_composer_header_table_get_header (table, E_COMPOSER_HEADER_POST_TO);
+ if (e_composer_header_get_visible (post_to_header)) {
+ GList *postlist;
+
+ postlist = e_composer_header_table_get_post_to (table);
+ num_post = g_list_length (postlist);
+ g_list_foreach (postlist, (GFunc)g_free, NULL);
+ g_list_free (postlist);
+ }
/* I'm sensing a lack of love, er, I mean recipients. */
if (num == 0 && num_post == 0) {
@@ -360,6 +414,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
goto finished;
}
+ if (invalid_addrs) {
+ if (e_error_run ((GtkWindow *)composer, strstr (invalid_addrs->str, ", ") ? "mail:ask-send-invalid-recip-multi" : "mail:ask-send-invalid-recip-one", invalid_addrs->str, NULL) == GTK_RESPONSE_CANCEL) {
+ g_string_free (invalid_addrs, TRUE);
+ goto finished;
+ }
+
+ g_string_free (invalid_addrs, TRUE);
+ }
+
if (num > 0 && (num == num_bcc || shown == 0)) {
/* this means that the only recipients are Bcc's */
if (!ask_confirm_for_only_bcc (composer, shown == 0))
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 62c8b53da3..6f7b62b615 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -15,8 +15,8 @@
<_primary>Are you sure you want to send a message in HTML format?</_primary>
<_secondary xml:space="preserve">Please make sure the following recipients are willing and able to receive HTML email:
{0}</_secondary>
- <button _label="_Send" response="GTK_RESPONSE_YES"/>
<button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
</error>
<error id="ask-send-no-subject" type="question" default="GTK_RESPONSE_YES">
@@ -42,6 +42,22 @@ Many email systems add an Apparently-To header to messages that only have BCC re
<button _label="_Send" response="GTK_RESPONSE_YES"/>
</error>
+ <error id="ask-send-invalid-recip-one" type="question" default="GTK_RESPONSE_YES">
+ <_primary>Are you sure you want to send a message with invalid address?</_primary>
+ <_secondary xml:space="preserve">The following recipient was not recognized as a valid mail address:
+{0}</_secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
+ </error>
+
+ <error id="ask-send-invalid-recip-multi" type="question" default="GTK_RESPONSE_YES">
+ <_primary>Are you sure you want to send a message with invalid addresses?</_primary>
+ <_secondary xml:space="preserve">The following recipients were not recognized as valid mail addresses:
+{0}</_secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
+ </error>
+
<error id="send-no-recipients" type="warning">
<_primary>This message cannot be sent because you have not specified any recipients</_primary>
<_secondary xml:space="preserve">Please enter a valid email address in the To: field. You can search for email addresses by clicking on the To: button next to the entry box.</_secondary>