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);
}
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;
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;
* @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_ */
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);