[evolution/gnome-3-16] Correct signature stripping in HTML messages



commit 72d09a400cc6fb52c1bf27d4e1e4644e423fa6a4
Author: Milan Crha <mcrha redhat com>
Date:   Tue May 19 19:44:15 2015 +0200

    Correct signature stripping in HTML messages
    
    The line divider in HTML messages is the <BR> tag, but the code was
    looking for '\n' only, thus it could skip the right place very easily.

 em-format/e-mail-stripsig-filter.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/em-format/e-mail-stripsig-filter.c b/em-format/e-mail-stripsig-filter.c
index f706913..db68689 100644
--- a/em-format/e-mail-stripsig-filter.c
+++ b/em-format/e-mail-stripsig-filter.c
@@ -47,10 +47,14 @@ strip_signature (CamelMimeFilter *filter,
        const gchar *start = NULL;
 
        if (stripsig->midline) {
-               while (inptr < inend && *inptr != '\n')
+               while (inptr < inend && *inptr != '\n' && (stripsig->text_plain_only ||
+                      inend - inptr < 4 || g_ascii_strncasecmp (inptr, "<BR>", 4) != 0))
                        inptr++;
 
-               if (inptr < inend) {
+               if (!stripsig->text_plain_only && inend - inptr >= 4 && g_ascii_strncasecmp (inptr, "<BR>", 
4) == 0) {
+                       stripsig->midline = FALSE;
+                       inptr += 4;
+               } else if (inptr < inend) {
                        stripsig->midline = FALSE;
                        inptr++;
                }
@@ -66,7 +70,8 @@ strip_signature (CamelMimeFilter *filter,
                        start = inptr;
                        inptr += 7;
                } else {
-                       while (inptr < inend && *inptr != '\n')
+                       while (inptr < inend && *inptr != '\n' && (stripsig->text_plain_only ||
+                              inend - inptr < 4 || g_ascii_strncasecmp (inptr, "<BR>", 4) != 0))
                                inptr++;
 
                        if (inptr == inend) {
@@ -74,7 +79,10 @@ strip_signature (CamelMimeFilter *filter,
                                break;
                        }
 
-                       inptr++;
+                       if (!stripsig->text_plain_only && inend - inptr >= 4 && g_ascii_strncasecmp (inptr, 
"<BR>", 4) == 0)
+                               inptr += 4;
+                       else
+                               inptr++;
                }
        }
 


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