@@ -951,7 +951,9 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input, GError *err | |||
g_string_erase (symbuf, symbuf->len - 1, 1); | |||
} | |||
folded_symbuf = rspamd_header_value_fold ("X-Spam-Symbols", symbuf->str); | |||
folded_symbuf = rspamd_header_value_fold ("X-Spam-Symbols", | |||
symbuf->str, | |||
0); | |||
g_mime_object_append_header (GMIME_OBJECT (message), "X-Spam-Symbols", | |||
symbuf->str); | |||
g_string_free (folded_symbuf, TRUE); |
@@ -865,10 +865,12 @@ rspamd_strings_levenshtein_distance (const gchar *s1, gsize s1len, | |||
} | |||
GString * | |||
rspamd_header_value_fold (const gchar *name, const gchar *value) | |||
rspamd_header_value_fold (const gchar *name, | |||
const gchar *value, | |||
guint fold_max) | |||
{ | |||
GString *res; | |||
const guint fold_max = 76; | |||
const guint default_fold_max = 76; | |||
guint cur_len; | |||
const gchar *p, *c; | |||
gboolean first_token = TRUE; | |||
@@ -886,6 +888,11 @@ rspamd_header_value_fold (const gchar *name, const gchar *value) | |||
g_assert (name != NULL); | |||
g_assert (value != NULL); | |||
/* Filter insane values */ | |||
if (fold_max < 20) { | |||
fold_max = default_fold_max; | |||
} | |||
res = g_string_sized_new (strlen (value)); | |||
c = value; |
@@ -168,6 +168,8 @@ gint rspamd_strings_levenshtein_distance (const gchar *s1, gsize s1len, | |||
* @param value value of header | |||
* @return new GString with the folded value | |||
*/ | |||
GString * rspamd_header_value_fold (const gchar *name, const gchar *value); | |||
GString *rspamd_header_value_fold (const gchar *name, | |||
const gchar *value, | |||
guint fold_max); | |||
#endif /* SRC_LIBUTIL_STR_UTIL_H_ */ |
@@ -613,7 +613,7 @@ lua_util_fold_header (lua_State *L) | |||
value = luaL_checkstring (L, 2); | |||
if (name && value) { | |||
folded = rspamd_header_value_fold (name, value); | |||
folded = rspamd_header_value_fold (name, value, 0); | |||
if (folded) { | |||
lua_pushlstring (L, folded->str, folded->len); |