aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-01 12:18:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-01 12:18:58 +0100
commite3079ec0183ba274ef58822f548e020249be23fa (patch)
tree7c2b7e26c0d729b799f385bae63a57735d1317e4 /src/lua
parentfcaf800bd6cddb56c1cd88044346996d1f8854ee (diff)
downloadrspamd-e3079ec0183ba274ef58822f548e020249be23fa.tar.gz
rspamd-e3079ec0183ba274ef58822f548e020249be23fa.zip
[Minor] Add mimepart:get_raw_content method
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_mimepart.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 9c1d826d7..080bf4662 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -264,11 +264,17 @@ end
LUA_FUNCTION_DEF (mimepart, get_header_full);
/***
* @method mime_part:get_content()
- * Get the raw content of part
+ * Get the parsed content of part
* @return {text} opaque text object (zero-copy if not casted to lua string)
*/
LUA_FUNCTION_DEF (mimepart, get_content);
/***
+ * @method mime_part:get_raw_content()
+ * Get the raw content of part
+ * @return {text} opaque text object (zero-copy if not casted to lua string)
+ */
+LUA_FUNCTION_DEF (mimepart, get_raw_content);
+/***
* @method mime_part:get_length()
* Get length of the content of the part
* @return {integer} length of part in **bytes**
@@ -395,6 +401,7 @@ LUA_FUNCTION_DEF (mimepart, headers_foreach);
static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, get_content),
+ LUA_INTERFACE_DEF (mimepart, get_raw_content),
LUA_INTERFACE_DEF (mimepart, get_length),
LUA_INTERFACE_DEF (mimepart, get_type),
LUA_INTERFACE_DEF (mimepart, get_type_full),
@@ -918,6 +925,26 @@ lua_mimepart_get_content (lua_State * L)
}
static gint
+lua_mimepart_get_raw_content (lua_State * L)
+{
+ struct rspamd_mime_part *part = lua_check_mimepart (L);
+ struct rspamd_lua_text *t;
+
+ if (part == NULL) {
+ lua_pushnil (L);
+ return 1;
+ }
+
+ t = lua_newuserdata (L, sizeof (*t));
+ rspamd_lua_setclass (L, "rspamd{text}", -1);
+ t->start = part->raw_data.begin;
+ t->len = part->raw_data.len;
+ t->flags = 0;
+
+ return 1;
+}
+
+static gint
lua_mimepart_get_length (lua_State * L)
{
struct rspamd_mime_part *part = lua_check_mimepart (L);