aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-09 16:03:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-09 16:03:06 +0100
commit259cab02423faae0435695bc39e169b696b3d1fd (patch)
treedefe75b5bb926bfc199b7171c65eb1803ca31071 /src
parent983883f45b57c8772256c68d6dbd51539f80e654 (diff)
downloadrspamd-259cab02423faae0435695bc39e169b696b3d1fd.tar.gz
rspamd-259cab02423faae0435695bc39e169b696b3d1fd.zip
Allow to change fold_max variable.
Diffstat (limited to 'src')
-rw-r--r--src/client/rspamc.c4
-rw-r--r--src/libutil/str_util.c11
-rw-r--r--src/libutil/str_util.h4
-rw-r--r--src/lua/lua_util.c2
4 files changed, 16 insertions, 5 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index 1ac8a4397..07699fdfb 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -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);
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index 844962c25..2203cf0d4 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -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;
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h
index dcccc3d25..1d0a9eadb 100644
--- a/src/libutil/str_util.h
+++ b/src/libutil/str_util.h
@@ -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_ */
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 24c1bd676..f533434ce 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -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);