diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-18 16:31:15 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-18 16:31:15 +0000 |
commit | f286abaac361de836a276172ce9e46e4c058b75d (patch) | |
tree | 235a4b6684111d6db31d527f6e7918f7f9020cf1 /src/lua/lua_util.c | |
parent | a282883e6f9d70a787970e92dc3d7644661cd8a3 (diff) | |
download | rspamd-f286abaac361de836a276172ce9e46e4c058b75d.tar.gz rspamd-f286abaac361de836a276172ce9e46e4c058b75d.zip |
[Fix] More fixes to rfc2047 encoding
Diffstat (limited to 'src/lua/lua_util.c')
-rw-r--r-- | src/lua/lua_util.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index 251d1e1e7..e92e4977a 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -644,9 +644,10 @@ LUA_FUNCTION_DEF(util, get_hostname); LUA_FUNCTION_DEF(util, parse_content_type); /*** - * @function util.mime_header_encode(hdr) + * @function util.mime_header_encode(hdr[, is_structured]) * Encodes header if needed * @param {string} hdr input header + * @param {boolean} is_structured if true, then we encode as structured header (e.g. encode all non alpha-numeric characters) * @return encoded header */ LUA_FUNCTION_DEF(util, mime_header_encode); @@ -2406,15 +2407,19 @@ static int lua_util_mime_header_encode(lua_State *L) { LUA_TRACE_POINT; - gsize len; - const char *hdr = luaL_checklstring(L, 1, &len); + struct rspamd_lua_text *hdr = lua_check_text_or_string(L, 1); char *encoded; + bool is_structured = false; if (!hdr) { return luaL_error(L, "invalid arguments"); } - encoded = rspamd_mime_header_encode(hdr, len); + if (lua_isboolean(L, 2)) { + is_structured = lua_toboolean(L, 2); + } + + encoded = rspamd_mime_header_encode(hdr->start, hdr->len, is_structured); lua_pushstring(L, encoded); g_free(encoded); |