From: Vsevolod Stakhov Date: Wed, 15 Jul 2020 14:51:22 +0000 (+0100) Subject: [Fix] Improve part:is_attachment logic X-Git-Tag: 2.6~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=388dd3f53f65474c73cdeea675ce9569692da371;p=thirdparty%2Frspamd.git [Fix] Improve part:is_attachment logic --- diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index e183b6ae60..9748cfde33 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;