aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-24 23:59:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-24 23:59:31 +0100
commit5ebc4f7215714626e2a3eb6bb617a423c984a4b1 (patch)
tree89eeceef6a810f80116b79344494a965d4970670 /src
parent3c5de0377a4edaa6ad65043350688df189020de6 (diff)
downloadrspamd-5ebc4f7215714626e2a3eb6bb617a423c984a4b1.tar.gz
rspamd-5ebc4f7215714626e2a3eb6bb617a423c984a4b1.zip
[Minor] Allow to fold header in a different way using Lua API
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_util.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index aef1b7976..ec825c30f 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);