From: Vsevolod Stakhov Date: Sat, 24 Jun 2017 22:59:31 +0000 (+0100) Subject: [Minor] Allow to fold header in a different way using Lua API X-Git-Tag: 1.6.2~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ebc4f7215714626e2a3eb6bb617a423c984a4b1;p=thirdparty%2Frspamd.git [Minor] Allow to fold header in a different way using Lua API --- diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index aef1b79762..ec825c30f3 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -1127,15 +1127,34 @@ lua_util_parse_addr (lua_State *L) static gint lua_util_fold_header (lua_State *L) { - const gchar *name, *value; + const gchar *name, *value, *how; GString *folded; name = luaL_checkstring (L, 1); value = luaL_checkstring (L, 2); if (name && value) { - folded = rspamd_header_value_fold (name, value, 0, - RSPAMD_TASK_NEWLINES_CRLF); + + if (lua_isstring (L, 3)) { + how = lua_tostring (L, 3); + + if (g_ascii_strcasecmp (how, "cr") == 0) { + folded = rspamd_header_value_fold (name, value, 0, + RSPAMD_TASK_NEWLINES_CR); + } + else if (g_ascii_strcasecmp (how, "lf") == 0) { + folded = rspamd_header_value_fold (name, value, 0, + RSPAMD_TASK_NEWLINES_LF); + } + else { + folded = rspamd_header_value_fold (name, value, 0, + RSPAMD_TASK_NEWLINES_CRLF); + } + } + else { + folded = rspamd_header_value_fold (name, value, 0, + RSPAMD_TASK_NEWLINES_CRLF); + } if (folded) { lua_pushlstring (L, folded->str, folded->len);