aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_mimepart.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-15 15:51:22 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-15 15:51:22 +0100
commit388dd3f53f65474c73cdeea675ce9569692da371 (patch)
treec9676f3570e834fd5d5cf536021bc800afa249b7 /src/lua/lua_mimepart.c
parentec474468904ddd56716e3574e3cc8e7ceaeed812 (diff)
downloadrspamd-388dd3f53f65474c73cdeea675ce9569692da371.tar.gz
rspamd-388dd3f53f65474c73cdeea675ce9569692da371.zip
[Fix] Improve part:is_attachment logic
Diffstat (limited to 'src/lua/lua_mimepart.c')
-rw-r--r--src/lua/lua_mimepart.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index e183b6ae6..9748cfde3 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -1764,22 +1764,27 @@ lua_mimepart_is_attachment (lua_State * L)
return luaL_error (L, "invalid arguments");
}
- if (part->part_type != RSPAMD_MIME_PART_IMAGE) {
- if (part->cd && part->cd->type == RSPAMD_CT_ATTACHMENT) {
- lua_pushboolean (L, true);
- }
- else {
- if (part->cd && part->cd->filename.len > 0) {
- /* We still have filename and it is not an image */
+ if (part->cd && part->cd->type == RSPAMD_CT_ATTACHMENT) {
+ lua_pushboolean (L, true);
+ }
+ else {
+ /* if has_name and not (image and Content-ID_header_present) */
+ if (part->cd && part->cd->filename.len > 0) {
+ if (part->part_type != RSPAMD_MIME_PART_IMAGE &&
+ rspamd_message_get_header_from_hash (part->raw_headers,
+ "Content-Id") == NULL) {
+ /* Filename is presented but no content id and not image */
lua_pushboolean (L, true);
}
else {
+ /* Image or an embeded object */
lua_pushboolean (L, false);
}
}
- }
- else {
- lua_pushboolean (L, false);
+ else {
+ /* No filename */
+ lua_pushboolean (L, false);
+ }
}
return 1;