]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Another change of newlines policy
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jul 2016 12:30:13 +0000 (13:30 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jul 2016 12:30:13 +0000 (13:30 +0100)
Now we need to decide, maybe we have the following cases where '\n' is
required:

1. Multiple newlines must be replaced by one newline
2. If a line is finished with punctuation character, then insert one newline
3. In HTML parts we have to insert newlines as well

src/libmime/message.c

index 4d955c8e94196a3ce6a6f2c2ce9f43bc9da8f9b0..6e4e69597a69a67a31b7fa6e1cbd0e00b7d9ac63 100644 (file)
@@ -806,6 +806,22 @@ rspamd_normalize_text_part (struct rspamd_task *task,
                                g_byte_array_append (part->stripped_content, c, p - c);
                        }
 
+                       /*
+                        * Now we need to decide, maybe we have the following cases:
+                        * 1. Multiple newlines must be replaced by one newline
+                        * 2. If a line is finished with punctuation character, then insert
+                        * one newline
+                        * 3. In HTML parts we have to insert newlines as well
+                        */
+
+                       if (p > part->content->data &&
+                                       (IS_PART_HTML (part) ||
+                                       *(p - 1) == '\n' ||
+                                       g_ascii_ispunct (*(p - 1))
+                                       )) {
+                               g_byte_array_append (part->stripped_content, "\n", 1);
+                       }
+
                        /* As it could cause reallocation, we initially store offsets */
                        g_ptr_array_add (part->newlines,
                                        GUINT_TO_POINTER (part->stripped_content->len));