diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-02 15:34:39 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-02 15:34:39 +0100 |
commit | e12505a1471199f5d45f1799ce615ed06a87dc56 (patch) | |
tree | a101e333638eacd9e5591a9a386083516a624391 | |
parent | e6b7135b96d535bc27abba153090739942ecc984 (diff) | |
download | rspamd-e12505a1471199f5d45f1799ce615ed06a87dc56.tar.gz rspamd-e12505a1471199f5d45f1799ce615ed06a87dc56.zip |
[Fix] Fix fold_after case to preserve multiple spaces
-rw-r--r-- | src/libutil/str_util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 29df7e744..5fe8774a6 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -1028,9 +1028,23 @@ rspamd_header_value_fold (const gchar *name, case fold_token: /* Here, we have token start at 'c' and token end at 'p' */ if (fold_type == fold_after) { + guint nspaces = 0; + const gchar *last; if (p > c) { g_string_append_len (res, c, p - c); + + /* + * Check any spaces that are appended to the result + * before folding + */ + last = &res->str[res->len - 1]; + + while (g_ascii_isspace (*last)) { + last --; + nspaces ++; + res->len --; + } } switch (how) { @@ -1051,6 +1065,12 @@ rspamd_header_value_fold (const gchar *name, p ++; } + /* Move leftover spaces */ + while (nspaces) { + g_string_append_c (res, ' '); + nspaces --; + } + cur_len = 0; } else { |