aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_mimepart.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-05 14:59:14 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-05 14:59:14 +0000
commit15e41fc12fd50d7e35bc977f7a941c9b21ff15ff (patch)
tree152076ff61656be699fc130458a07c05d7e55314 /src/lua/lua_mimepart.c
parent200a8fb20eb8df438e88abf5525412b12c06d31f (diff)
downloadrspamd-15e41fc12fd50d7e35bc977f7a941c9b21ff15ff.tar.gz
rspamd-15e41fc12fd50d7e35bc977f7a941c9b21ff15ff.zip
[Minor] Lua_mimepart: Add `get_enclosing_boundary` method
Diffstat (limited to 'src/lua/lua_mimepart.c')
-rw-r--r--src/lua/lua_mimepart.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 1f6a62f40..c03ef35fd 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -469,6 +469,14 @@ LUA_FUNCTION_DEF (mimepart, is_message);
LUA_FUNCTION_DEF (mimepart, get_boundary);
/***
+ * @method mime_part:get_enclosing_boundary()
+ * Returns an enclosing boundary for a part even for multiparts. For normal parts
+ * this method is identical to `get_boundary`
+ * @return {string} boundary value or nil
+ */
+LUA_FUNCTION_DEF (mimepart, get_enclosing_boundary);
+
+/***
* @method mime_part:get_children()
* Returns rspamd_mimepart table of part's childer. Returns nil if mime part is not multipart
* or a message part.
@@ -569,6 +577,7 @@ static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, get_cte),
LUA_INTERFACE_DEF (mimepart, get_filename),
LUA_INTERFACE_DEF (mimepart, get_boundary),
+ LUA_INTERFACE_DEF (mimepart, get_enclosing_boundary),
LUA_INTERFACE_DEF (mimepart, get_header),
LUA_INTERFACE_DEF (mimepart, get_header_raw),
LUA_INTERFACE_DEF (mimepart, get_header_full),
@@ -1640,6 +1649,29 @@ lua_mimepart_get_boundary (lua_State * L)
}
static gint
+lua_mimepart_get_enclosing_boundary (lua_State * L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_mime_part *part = lua_check_mimepart (L), *parent;
+
+ if (part == NULL) {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ parent = part->parent_part;
+
+ if (!parent || !IS_PART_MULTIPART (parent)) {
+ lua_pushnil (L);
+ }
+ else {
+ lua_pushlstring (L, parent->specific.mp->boundary.begin,
+ parent->specific.mp->boundary.len);
+ }
+
+ return 1;
+}
+
+static gint
lua_mimepart_get_header_common (lua_State *L, enum rspamd_lua_task_header_type how)
{
struct rspamd_mime_part *part = lua_check_mimepart (L);