[evolution-data-server] CamelMimeParser: Correct body content parse when CRLF is used



commit db8998637c0b02ae85d9012c91f85c63c631874e
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 17 16:18:04 2022 +0100

    CamelMimeParser: Correct body content parse when CRLF is used
    
    The ending LF before a message part boundary is removed, but the code
    left there the CR, which is a part of the CRLF, in error, thus skip it
    as well, to not generate invalid body content.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/372

 src/camel/camel-mime-parser.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-mime-parser.c b/src/camel/camel-mime-parser.c
index 8c4ec7696..f7fb2ee2f 100644
--- a/src/camel/camel-mime-parser.c
+++ b/src/camel/camel-mime-parser.c
@@ -1547,9 +1547,12 @@ normal_exit:
 
        *data = start;
        /* if we hit a boundary, we should not include the closing \n */
-       if (onboundary && (inptr - start) > 0)
+       if (onboundary && (inptr - start) > 0) {
                *length = inptr-start-1;
-       else
+               /* in case it was "\r\n", remove also the "\r" */
+               if (*length > 0 && start[*length - 1] == '\r')
+                       *length = (*length) - 1;
+       } else
                *length = inptr-start;
 
        /*printf("got %scontent: '%.*s'\n", s->midline?"partial ":"", inptr-start, start);*/


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