diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-17 12:33:03 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-17 12:33:03 +0000 |
commit | b07563f21324253b5e4aa6f1531f98a0f313d59c (patch) | |
tree | 8c6e452dfa59dc7db394a364579f0c37c81dbc0a /src | |
parent | d6003a3997a914b9441a57281061dbaa3de26f08 (diff) | |
download | rspamd-b07563f21324253b5e4aa6f1531f98a0f313d59c.tar.gz rspamd-b07563f21324253b5e4aa6f1531f98a0f313d59c.zip |
[Minor] Add method to get raw headers of a mime part
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_mimepart.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index 3019cf577..56fc0d302 100644 --- a/src/lua/lua_mimepart.c +++ b/src/lua/lua_mimepart.c @@ -301,6 +301,15 @@ LUA_FUNCTION_DEF (mimepart, get_header_full); * @return {number} number of header's occurrencies or 0 if not found */ LUA_FUNCTION_DEF (mimepart, get_header_count); + +/*** + * @method mimepart:get_raw_headers() + * Get all undecoded headers of a mime part as a string + * @return {rspamd_text} all raw headers for a message as opaque text + */ +LUA_FUNCTION_DEF (mimepart, get_raw_headers); + + /*** * @method mime_part:get_content() * Get the parsed content of part @@ -479,6 +488,7 @@ static const struct luaL_reg mimepartlib_m[] = { LUA_INTERFACE_DEF (mimepart, get_header_raw), LUA_INTERFACE_DEF (mimepart, get_header_full), LUA_INTERFACE_DEF (mimepart, get_header_count), + LUA_INTERFACE_DEF (mimepart, get_raw_headers), LUA_INTERFACE_DEF (mimepart, is_image), LUA_INTERFACE_DEF (mimepart, get_image), LUA_INTERFACE_DEF (mimepart, is_archive), @@ -1236,7 +1246,7 @@ lua_mimepart_get_type_common (lua_State * L, struct rspamd_content_type *ct, } if (ct->boundary.len > 0) { - lua_pushstring (L, "charset"); + lua_pushstring (L, "boundary"); lua_pushlstring (L, ct->boundary.begin, ct->boundary.len); lua_settable (L, -3); } @@ -1394,6 +1404,28 @@ lua_mimepart_get_header_count (lua_State * L) } static gint +lua_mimepart_get_raw_headers (lua_State *L) +{ + LUA_TRACE_POINT; + struct rspamd_mime_part *part = lua_check_mimepart (L); + struct rspamd_lua_text *t; + + if (part) { + t = lua_newuserdata (L, sizeof (*t)); + rspamd_lua_setclass (L, "rspamd{text}", -1); + t->start = part->raw_headers_str; + t->len = part->raw_headers_len; + t->flags = 0; + } + else { + return luaL_error (L, "invalid arguments"); + } + + + return 1; +} + +static gint lua_mimepart_is_image (lua_State * L) { LUA_TRACE_POINT; |