From: Vsevolod Stakhov Date: Thu, 30 Mar 2017 13:26:29 +0000 (+0100) Subject: [Fix] Try to avoid modifications of the original data X-Git-Tag: 1.5.5~77 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=30324e7c53dff01bc477b592a24a1f8cc0037406;p=rspamd.git [Fix] Try to avoid modifications of the original data --- diff --git a/src/libserver/html.c b/src/libserver/html.c index b0bea5b83..31a602e8d 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -2111,16 +2111,22 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, else if (g_ascii_isspace (t)) { save_space = TRUE; - if (c != p) { + if (p > c) { if (need_decode) { - len = rspamd_html_decode_entitles_inplace ((gchar *)c, + goffset old_offset = dest->len; + + g_byte_array_append (dest, c, (p - c)); + + len = rspamd_html_decode_entitles_inplace ( + dest->data + old_offset, p - c); + dest->len = dest->len + len - (p - c); } else { len = p - c; + g_byte_array_append (dest, c, len); } - g_byte_array_append (dest, c, len); if (content_tag) { if (content_tag->content == NULL) { content_tag->content = c; @@ -2148,14 +2154,19 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, if (c != p) { if (need_decode) { - len = rspamd_html_decode_entitles_inplace ((gchar *)c, + goffset old_offset = dest->len; + + g_byte_array_append (dest, c, (p - c)); + len = rspamd_html_decode_entitles_inplace ( + dest->data + old_offset, p - c); + dest->len = dest->len + len - (p - c); } else { len = p - c; + g_byte_array_append (dest, c, len); } - g_byte_array_append (dest, c, len); if (content_tag) { if (content_tag->content == NULL) {