[evolution-data-server] Bug 791475 - Incorrectly parses headers in certain case ]I[



commit d99273664f33daed9c507188e26f89a4a212ee45
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 12 18:03:44 2018 +0200

    Bug 791475 - Incorrectly parses headers in certain case ]I[

 src/camel/camel-mime-parser.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-mime-parser.c b/src/camel/camel-mime-parser.c
index c8869f1..a241606 100644
--- a/src/camel/camel-mime-parser.c
+++ b/src/camel/camel-mime-parser.c
@@ -1320,6 +1320,12 @@ folder_scan_header (struct _header_scan_state *s,
                                                if (s->outptr - 1 > s->outbuf && (s->outptr[-2] == '\r' || 
s->outptr[-2] == '\n'))
                                                        s->outptr[-2] = 0;
 
+                                               if (s->outbuf == s->outptr || !*s->outbuf) {
+                                                       s->check_header_folded = FALSE;
+                                                       s->midline = FALSE;
+                                                       goto header_done;
+                                               }
+
                                                h (printf ("header not folded '%s' at %d\n", s->outbuf, 
(gint) s->header_start));
 
                                                header_raw_append_parse (&h->headers, s->outbuf, 
s->header_start);
@@ -1341,9 +1347,9 @@ folder_scan_header (struct _header_scan_state *s,
                                        s->midline = TRUE;
                                        s->check_header_folded = inptr == inend;
                                        inptr = inend;
-                                       header_append (s, start, inptr);
+                                       header_append (s, start, inptr + (s->check_header_folded ? -1 : 0));
                                } else {
-                                       h (printf ("got line part: '%.*s'\n", inptr - 1 - start, start));
+                                       h (printf ("got line part: '%.*s'\n", (gint) (inptr - 1 - start), 
start));
                                        /* got a line, strip and add it, process it */
                                        s->midline = FALSE;
                                        s->check_header_folded = FALSE;


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