aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-30 14:26:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-30 14:28:13 +0100
commit30324e7c53dff01bc477b592a24a1f8cc0037406 (patch)
treec6f6736a73b4b86ac05acd44622a6deabe0ecbf8 /src/libserver
parentfc559aa0ba6b51cc641fe0b6051c052d819db5da (diff)
downloadrspamd-30324e7c53dff01bc477b592a24a1f8cc0037406.tar.gz
rspamd-30324e7c53dff01bc477b592a24a1f8cc0037406.zip
[Fix] Try to avoid modifications of the original data
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/html.c21
1 files changed, 16 insertions, 5 deletions
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) {