[evolution-data-server/gnome-40] CamelMimeFilterToHTML: Correct filtering of text without new line at the end



commit d1802925e8c61293b5b0b374edf84923ce821f9c
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jul 21 12:50:25 2021 +0200

    CamelMimeFilterToHTML: Correct filtering of text without new line at the end
    
    When the text had no new line at the end, the last line could be skipped
    in the filter output. This had been caused by the previous commit.

 src/camel/camel-mime-filter-tohtml.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/camel/camel-mime-filter-tohtml.c b/src/camel/camel-mime-filter-tohtml.c
index da39ed5dc..6731635b7 100644
--- a/src/camel/camel-mime-filter-tohtml.c
+++ b/src/camel/camel-mime-filter-tohtml.c
@@ -292,7 +292,7 @@ html_convert (CamelMimeFilter *mime_filter,
 
        priv = CAMEL_MIME_FILTER_TOHTML (mime_filter)->priv;
 
-       if (inlen == 0) {
+       if (inlen == 0 && !priv->backup) {
                if (!priv->pre_open && !priv->div_open && !priv->blockquote_depth) {
                        /* No closing tags needed. */
                        *out = (gchar *) in;
@@ -332,8 +332,22 @@ html_convert (CamelMimeFilter *mime_filter,
 
        camel_mime_filter_set_size (mime_filter, inlen * 2 + 6, FALSE);
 
-       inptr = in;
-       inend = in + inlen;
+       if (inlen == 0 && priv->backup) {
+               gsize backup_len;
+
+               backup_len = priv->backup->len;
+               backup_str = g_string_free (priv->backup, FALSE);
+               priv->backup = NULL;
+
+               inptr = backup_str + backup_len;
+               inend = inptr;
+               start = backup_str;
+       } else {
+               inptr = in;
+               inend = in + inlen;
+               start = inptr;
+       }
+
        outptr = mime_filter->outbuf;
        outend = mime_filter->outbuf + mime_filter->outsize;
 
@@ -343,7 +357,6 @@ html_convert (CamelMimeFilter *mime_filter,
                priv->pre_open = TRUE;
        }
 
-       start = inptr;
        do {
                while (inptr < inend && *inptr != '\n')
                        inptr++;


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