aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-22 13:30:13 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-22 13:30:13 +0100
commit559ba376145554ccc9de3540cb6243af84381578 (patch)
treec0567e44f4665c86526ecdd73a549999bb3fb82d
parentcb9f7934192eb974d287581d4ff997e3b1a25716 (diff)
downloadrspamd-559ba376145554ccc9de3540cb6243af84381578.tar.gz
rspamd-559ba376145554ccc9de3540cb6243af84381578.zip
[Fix] Another change of newlines policy
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
-rw-r--r--src/libmime/message.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 4d955c8e9..6e4e69597 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -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));