aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-31 12:19:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-31 12:19:43 +0000
commit9dcae9b27979fd4acc541d89877d74e6dc8e0980 (patch)
tree783fbc854a84cfe4e3d9a37ca2239fc34080f7a8 /src
parentb0030d4cd663ba83261ffb3965f31c64d27b8778 (diff)
downloadrspamd-9dcae9b27979fd4acc541d89877d74e6dc8e0980.tar.gz
rspamd-9dcae9b27979fd4acc541d89877d74e6dc8e0980.zip
[Fix] Core: Fix headers folding on the last token
Diffstat (limited to 'src')
-rw-r--r--src/libutil/str_util.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index e72962904..2e09e48f3 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -1394,7 +1394,33 @@ rspamd_header_value_fold (const gchar *name,
case after_quote:
g_string_append_len (res, c, p - c);
break;
-
+ case fold_token:
+ /* Here, we have token start at 'c' and token end at 'p' */
+ if (g_ascii_isspace (res->str[res->len - 1])) {
+ g_string_append_len (res, c, p - c);
+ }
+ else {
+ if (*c != '\r' && *c != '\n') {
+ /* We need to add folding as well */
+ switch (how) {
+ case RSPAMD_TASK_NEWLINES_LF:
+ g_string_append_len (res, "\n\t", 2);
+ break;
+ case RSPAMD_TASK_NEWLINES_CR:
+ g_string_append_len (res, "\r\t", 2);
+ break;
+ case RSPAMD_TASK_NEWLINES_CRLF:
+ default:
+ g_string_append_len (res, "\r\n\t", 3);
+ break;
+ }
+ g_string_append_len (res, c, p - c);
+ }
+ else {
+ g_string_append_len (res, c, p - c);
+ }
+ }
+ break;
default:
g_assert (p == c);
break;