eds-I#13 - [IMAPx] Fails to append message to Yahoo! with no CRLF at the end

This change makes sure the composer stores message text with CRLF
at the end. It was possible to save it without it before this change.

Related to https://gitlab.gnome.org/GNOME/evolution-data-server/issues/13
This commit is contained in:
Milan Crha
2018-06-27 17:27:57 +02:00
parent 2cb3aa872b
commit 20c604da06
3 changed files with 54 additions and 4 deletions

View File

@ -1310,6 +1310,8 @@ composer_build_message (EMsgComposer *composer,
}
g_byte_array_append (data, (guint8 *) text, strlen (text));
if (!g_str_has_suffix (text, "\r\n"))
g_byte_array_append (data, (const guint8 *) "\r\n", 2);
g_free (text);
type = camel_content_type_new ("text", "plain");
@ -1416,6 +1418,8 @@ composer_build_message (EMsgComposer *composer,
length = strlen (text);
g_byte_array_append (data, (guint8 *) text, (guint) length);
if (!g_str_has_suffix (text, "\r\n"))
g_byte_array_append (data, (const guint8 *) "\r\n", 2);
pre_encode = text_requires_quoted_printable (text, length);
g_free (text);
@ -5379,6 +5383,8 @@ e_msg_composer_get_raw_message_text_without_signature (EMsgComposer *composer)
EHTMLEditor *editor;
EContentEditor *cnt_editor;
gchar *content;
GByteArray *bytes;
gboolean needs_crlf;
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
@ -5397,7 +5403,14 @@ e_msg_composer_get_raw_message_text_without_signature (EMsgComposer *composer)
content = g_strdup ("");
}
return g_byte_array_new_take ((guint8 *) content, strlen (content));
needs_crlf = !g_str_has_suffix (content, "\r\n");
bytes = g_byte_array_new_take ((guint8 *) content, strlen (content));
if (needs_crlf)
g_byte_array_append (bytes, (const guint8 *) "\r\n", 2);
return bytes;
}
/**
@ -5411,6 +5424,8 @@ e_msg_composer_get_raw_message_text (EMsgComposer *composer)
EHTMLEditor *editor;
EContentEditor *cnt_editor;
gchar *content;
GByteArray *bytes;
gboolean needs_crlf;
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
@ -5428,7 +5443,14 @@ e_msg_composer_get_raw_message_text (EMsgComposer *composer)
content = g_strdup ("");
}
return g_byte_array_new_take ((guint8 *) content, strlen (content));
needs_crlf = !g_str_has_suffix (content, "\r\n");
bytes = g_byte_array_new_take ((guint8 *) content, strlen (content));
if (needs_crlf)
g_byte_array_append (bytes, (const guint8 *) "\r\n", 2);
return bytes;
}
gboolean

View File

@ -343,6 +343,13 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor)
NULL, NULL);
if (text && *text) {
if (!g_str_has_suffix (text, "\r\n")) {
gchar *tmp = text;
text = g_strconcat (tmp, "\r\n", NULL);
g_free (tmp);
}
part = camel_mime_part_new ();
camel_mime_part_set_content (part, text, strlen (text), "text/plain");
camel_multipart_add_part (multipart_alternative, part);
@ -366,10 +373,17 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor)
/* Text is required, thus if there are attachments,
but no text, then store at least a space. */
g_free (text);
text = g_strdup (" ");
text = g_strdup ("\r\n");
}
if (text && *text) {
if (!g_str_has_suffix (text, "\r\n")) {
gchar *tmp = text;
text = g_strconcat (tmp, "\r\n", NULL);
g_free (tmp);
}
part = camel_mime_part_new ();
camel_mime_part_set_content (part, text, strlen (text), "text/html");
camel_multipart_add_part (multipart_alternative, part);
@ -445,10 +459,17 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor)
/* Text is required, thus if there are attachments,
but no text, then store at least a space. */
g_free (text);
text = g_strdup (" ");
text = g_strdup ("\r\n");
}
if (text && *text) {
if (!g_str_has_suffix (text, "\r\n")) {
gchar *tmp = text;
text = g_strconcat (tmp, "\r\n", NULL);
g_free (tmp);
}
if (has_attachments) {
CamelMultipart *multipart;
CamelMimePart *part;

View File

@ -220,6 +220,13 @@ composer_to_meeting_component (EMsgComposer *composer)
ECalComponentText *description;
GSList *descr_list = NULL;
if (!g_str_has_suffix (text, "\r\n")) {
gchar *tmp = text;
text = g_strconcat (tmp, "\r\n", NULL);
g_free (tmp);
}
description = g_new0 (ECalComponentText, 1);
description->value = text;
description->altrep = NULL;