]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Be more carefull about newlines in html.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Sep 2015 12:47:28 +0000 (13:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Sep 2015 12:47:28 +0000 (13:47 +0100)
src/libserver/html.c

index 401c13f7a82cb5837067fccc1c987a102f29e91b..96380a3ef6ec3e3928362871c103b5881960a21b 100644 (file)
@@ -1887,10 +1887,14 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
                                        setbit (hc->tags_seen, cur_tag->id);
                                }
 
-                               if ((cur_tag->id == Tag_P || cur_tag->id == Tag_BR ||
-                                               cur_tag->id == Tag_HR) && balanced) {
+                               if ((cur_tag->flags & (FL_CLOSED|FL_CLOSING)) &&
+                                               (cur_tag->id == Tag_P || cur_tag->id == Tag_BR ||
+                                               cur_tag->id == Tag_HR || cur_tag->id == Tag_TR ||
+                                               cur_tag->id == Tag_DIV) && balanced) {
                                        /* Insert newline */
-                                       g_byte_array_append (dest, "\r\n", 2);
+                                       if (dest->data[dest->len - 1] != '\n') {
+                                               g_byte_array_append (dest, "\r\n", 2);
+                                       }
                                        save_space = FALSE;
                                }