]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Allow to change fold_max variable.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Sep 2015 15:03:06 +0000 (16:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Sep 2015 15:03:06 +0000 (16:03 +0100)
src/client/rspamc.c
src/libutil/str_util.c
src/libutil/str_util.h
src/lua/lua_util.c

index 1ac8a43977394c83fdc54141546cff68400dafce..07699fdfbb1acb23d1a4542079714e89231f1e97 100644 (file)
@@ -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);
index 844962c2510fab20977f7817ade4c4fa47893d84..2203cf0d4792537679e91ee48a8e63da0ceb158e 100644 (file)
@@ -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;
index dcccc3d25bdddbd5f66a194fd4af9be5fdbbda3c..1d0a9eadbe3813b96dfda7f778077079d64bcb94 100644 (file)
@@ -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_ */
index 24c1bd67660df6634922e17126b9665bf8d64b69..f533434ce1ce0abca39d4a3323cf6a85f0343560 100644 (file)
@@ -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);