]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix processing of <br> and <hr> tags
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Jul 2016 16:02:16 +0000 (17:02 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Jul 2016 16:07:23 +0000 (17:07 +0100)
src/libserver/html.c

index 7fbe585233b55597619643136d0f717633108be5..0a25e488a67bc6f65be2442e16bc6b7bb17b5bca 100644 (file)
@@ -1912,11 +1912,17 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
                                        setbit (hc->tags_seen, cur_tag->id);
                                }
 
-                               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 ||
+                               /* Handle newlines */
+                               if (cur_tag->id == Tag_BR || cur_tag->id == Tag_HR) {
+                                       if (dest->len > 0 && dest->data[dest->len - 1] != '\n') {
+                                               g_byte_array_append (dest, "\r\n", 2);
+                                       }
+                                       save_space = FALSE;
+                               }
+                               else if ((cur_tag->flags & (FL_CLOSED|FL_CLOSING)) &&
+                                               (cur_tag->id == Tag_P ||
+                                               cur_tag->id == Tag_TR ||
                                                cur_tag->id == Tag_DIV) && balanced) {
-                                       /* Insert newline */
                                        if (dest->len > 0 && dest->data[dest->len - 1] != '\n') {
                                                g_byte_array_append (dest, "\r\n", 2);
                                        }