[evolution/evolution-3-12] Bug 702703 - Do not use local machine's domain in Message IDs
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/evolution-3-12] Bug 702703 - Do not use local machine's domain in Message IDs
- Date: Tue, 17 Jun 2014 10:13:34 +0000 (UTC)
commit 50be4942bc2427756f9626a37c35179e2dc88c33
Author: Milan Crha <mcrha redhat com>
Date: Tue Jun 17 12:12:16 2014 +0200
Bug 702703 - Do not use local machine's domain in Message IDs
composer/e-msg-composer.c | 47 ++++++++++++++++++++++++++++++++++++++++--
modules/mdn/evolution-mdn.c | 16 +++++---------
2 files changed, 50 insertions(+), 13 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 944f40a..74ca819 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1071,6 +1071,45 @@ composer_add_evolution_format_header (CamelMedium *medium,
g_string_free (string, TRUE);
}
+static gchar *
+msg_composer_generate_msg_id (EMsgComposer *composer)
+{
+ CamelInternetAddress *from;
+ gchar *tmp, *msg_id;
+ const gchar *from_domain = NULL;
+
+ from = e_msg_composer_get_from (composer);
+ if (from && camel_internet_address_get (from, 0, NULL, &from_domain)) {
+ const gchar *at = strchr (from_domain, '@');
+ if (at)
+ from_domain = at + 1;
+ else
+ from_domain = NULL;
+ } else {
+ from_domain = NULL;
+ }
+
+ if (!from_domain || !*from_domain)
+ from_domain = "localhost";
+
+ msg_id = camel_header_msgid_generate ();
+ tmp = strchr (msg_id, '@');
+ if (!tmp) {
+ g_clear_object (&from);
+ return msg_id;
+ }
+
+ tmp[1] = '\0';
+
+ tmp = msg_id;
+ msg_id = g_strconcat (tmp, from_domain, NULL);
+
+ g_clear_object (&from);
+ g_free (tmp);
+
+ return msg_id;
+}
+
static void
composer_build_message (EMsgComposer *composer,
ComposerFlags flags,
@@ -1099,7 +1138,7 @@ composer_build_message (EMsgComposer *composer,
CamelMimePart *part;
GByteArray *data;
ESource *source;
- gchar *charset;
+ gchar *charset, *message_id;
gint i;
priv = composer->priv;
@@ -1161,7 +1200,9 @@ composer_build_message (EMsgComposer *composer,
/* Explicitly generate a Message-ID header here so it's
* consistent for all outbound streams (SMTP, Fcc, etc). */
- camel_mime_message_set_message_id (context->message, NULL);
+ message_id = msg_composer_generate_msg_id (composer);
+ camel_mime_message_set_message_id (context->message, message_id);
+ g_free (message_id);
build_message_headers (composer, context->message, FALSE);
for (i = 0; i < priv->extra_hdr_names->len; i++) {
@@ -4510,7 +4551,7 @@ e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
camel_medium_set_content (CAMEL_MEDIUM (part), wrapper);
g_object_unref (wrapper);
- cid = camel_header_msgid_generate ();
+ cid = msg_composer_generate_msg_id (composer);
camel_mime_part_set_content_id (part, cid);
name = g_path_get_basename (dec_file_name);
camel_mime_part_set_filename (part, name);
diff --git a/modules/mdn/evolution-mdn.c b/modules/mdn/evolution-mdn.c
index 07a68e2..0a46204 100644
--- a/modules/mdn/evolution-mdn.c
+++ b/modules/mdn/evolution-mdn.c
@@ -229,8 +229,7 @@ mdn_notify_sender (ESource *identity_source,
const gchar *transport_uid;
const gchar *self_address;
const gchar *sent_folder_uri;
- gchar *fake_msgid;
- gchar *hostname;
+ const gchar *hostname;
gchar *receipt_subject;
gchar *disposition;
gchar *recipient;
@@ -275,13 +274,11 @@ mdn_notify_sender (ESource *identity_source,
transport_uid = e_source_mail_submission_get_transport_uid (
E_SOURCE_MAIL_SUBMISSION (extension));
- /* We use camel_header_msgid_generate() to get a canonical
- * hostname, then skip the part leading to '@' */
- fake_msgid = camel_header_msgid_generate ();
- hostname = strchr (fake_msgid, '@');
- g_return_if_fail (hostname != NULL);
-
- hostname++;
+ hostname = self_address ? strchr (self_address, '@') : NULL;
+ if (hostname)
+ hostname++;
+ else
+ hostname = "localhost";
/* Create toplevel container. */
body = camel_multipart_new ();
@@ -351,7 +348,6 @@ mdn_notify_sender (ESource *identity_source,
g_free (ua);
g_free (recipient);
- g_free (fake_msgid);
g_free (disposition);
part = camel_mime_part_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]