From: Vsevolod Stakhov Date: Tue, 7 Mar 2017 11:48:26 +0000 (+0000) Subject: [Feature] Allow to extract CTE in Lua API X-Git-Tag: 1.5.2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f05496beabff912e4ff87c21a34bc4f2884fc33b;p=thirdparty%2Frspamd.git [Feature] Allow to extract CTE in Lua API --- diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index 1ff3dbd582..8a9fb85e11 100644 --- a/src/lua/lua_mimepart.c +++ b/src/lua/lua_mimepart.c @@ -226,9 +226,17 @@ LUA_FUNCTION_DEF (mimepart, get_length); /*** * @method mime_part:get_type() * Extract content-type string of the mime part - * @return {string} content type in form 'type/subtype' + * @return {string,string} content type in form 'type','subtype' */ LUA_FUNCTION_DEF (mimepart, get_type); + +/*** + * @method mime_part:get_cte() + * Extract content-transfer-encoding for a part + * @return {string} content transfer encoding (e.g. `base64` or `7bit`) + */ +LUA_FUNCTION_DEF (mimepart, get_cte); + /*** * @method mime_part:get_filename() * Extract filename associated with mime part if it is an attachement @@ -304,6 +312,7 @@ static const struct luaL_reg mimepartlib_m[] = { LUA_INTERFACE_DEF (mimepart, get_content), LUA_INTERFACE_DEF (mimepart, get_length), LUA_INTERFACE_DEF (mimepart, get_type), + LUA_INTERFACE_DEF (mimepart, get_cte), LUA_INTERFACE_DEF (mimepart, get_filename), LUA_INTERFACE_DEF (mimepart, get_header), LUA_INTERFACE_DEF (mimepart, get_header_raw), @@ -688,6 +697,21 @@ lua_mimepart_get_type (lua_State * L) return 2; } +static gint +lua_mimepart_get_cte (lua_State * L) +{ + struct rspamd_mime_part *part = lua_check_mimepart (L); + + if (part == NULL) { + lua_pushnil (L); + return 1; + } + + lua_pushstring (L, rspamd_cte_to_string (part->cte)); + + return 1; +} + static gint lua_mimepart_get_filename (lua_State * L) {