[evolution/wip/mcrha/webkit-jsc-api] Extra new line added at the end of the message text



commit 9ca0d53c53c94535b3a19816c6e3d25621e5c9a0
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 23 14:57:39 2020 +0200

    Extra new line added at the end of the message text
    
    No need to add "\r\n" at the end of the text, when it ends with "\n" already.

 src/composer/e-msg-composer.c | 8 ++++----
 src/mail/e-mail-notes.c       | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 07cfb1edbc..41a9f0a71f 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1457,7 +1457,7 @@ composer_build_message (EMsgComposer *composer,
                }
 
                g_byte_array_append (data, (guint8 *) text, strlen (text));
-               if (!g_str_has_suffix (text, "\r\n"))
+               if (!g_str_has_suffix (text, "\r\n") && !g_str_has_suffix (text, "\n"))
                        g_byte_array_append (data, (const guint8 *) "\r\n", 2);
 
                type = camel_content_type_new ("text", "plain");
@@ -1555,7 +1555,7 @@ 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"))
+               if (!g_str_has_suffix (text, "\r\n") && !g_str_has_suffix (text, "\n"))
                        g_byte_array_append (data, (const guint8 *) "\r\n", 2);
                pre_encode = text_requires_quoted_printable (text, length);
 
@@ -5942,7 +5942,7 @@ e_msg_composer_get_raw_message_text_without_signature (EMsgComposer *composer)
                content = "";
        }
 
-       needs_crlf = !g_str_has_suffix (content, "\r\n");
+       needs_crlf = !g_str_has_suffix (content, "\r\n") && !g_str_has_suffix (content, "\n");
 
        content_length = strlen (content);
 
@@ -5983,7 +5983,7 @@ e_msg_composer_get_raw_message_text (EMsgComposer *composer)
                content = "";
        }
 
-       needs_crlf = !g_str_has_suffix (content, "\r\n");
+       needs_crlf = !g_str_has_suffix (content, "\r\n") && !g_str_has_suffix (content, "\n");
 
        content_length = strlen (content);
 
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index 1caaadca18..d99e4b960e 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -344,7 +344,7 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                if (text && *text) {
                        gchar *tmp = NULL;
 
-                       if (!g_str_has_suffix (text, "\r\n")) {
+                       if (!g_str_has_suffix (text, "\r\n") && !g_str_has_suffix (text, "\n")) {
                                tmp = g_strconcat (text, "\r\n", NULL);
                                text = tmp;
                        }
@@ -371,7 +371,7 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                if (text && *text) {
                        gchar *tmp = NULL;
 
-                       if (!g_str_has_suffix (text, "\r\n")) {
+                       if (!g_str_has_suffix (text, "\r\n") && !g_str_has_suffix (text, "\n")) {
                                tmp = g_strconcat (text, "\r\n", NULL);
                                text = tmp;
                        }
@@ -449,7 +449,7 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                if (text && *text) {
                        gchar *tmp = NULL;
 
-                       if (!g_str_has_suffix (text, "\r\n")) {
+                       if (!g_str_has_suffix (text, "\r\n") && !g_str_has_suffix (text, "\n")) {
                                tmp = g_strconcat (text, "\r\n", NULL);
                                text = tmp;
                        }


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