diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-25 20:34:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-25 20:34:04 +0000 |
commit | b28cddd28f45383b725aad1662bb0a7b20b085b2 (patch) | |
tree | f18ff6aadb089e11c6c94261838ea684ff9e68e5 | |
parent | cd90981ee2bb70f0790cd9595da241c989dcd184 (diff) | |
parent | 41dab157a0787100773f672c74cf46ac7a5bd9fa (diff) | |
download | rspamd-b28cddd28f45383b725aad1662bb0a7b20b085b2.tar.gz rspamd-b28cddd28f45383b725aad1662bb0a7b20b085b2.zip |
Merge pull request #2731 from moisseev/mime_types
Mime types
-rw-r--r-- | src/plugins/lua/mime_types.lua | 4 | ||||
-rw-r--r-- | test/functional/cases/105_mimetypes.robot | 10 | ||||
-rw-r--r-- | test/functional/messages/next2last-digits_in_brackets.eml | 9 | ||||
-rw-r--r-- | test/functional/messages/next2last-digits_in_parens.eml | 9 |
4 files changed, 30 insertions, 2 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index a7a859e53..206284a25 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -479,7 +479,7 @@ local full_extensions_map = { {"mqv", "video/quicktime"}, {"ms", "application/x-troff-ms"}, {"msg", "application/vnd.ms-outlook"}, - {"msi", "application/octet-stream"}, + {"msi", {"application/x-msi", "application/octet-stream"}}, {"mso", "application/octet-stream"}, {"mts", "video/vnd.dlna.mpeg-tts"}, {"mtx", "application/xml"}, @@ -854,7 +854,7 @@ local function check_mime_type(task) if #parts > 2 then -- We need to ensure that next-to-last extension is an extension, -- so we check for its length and if it is not a number or date - if #ext2 <= 4 and not string.match(ext2, '^%d+$') then + if #ext2 <= 4 and not string.match(ext2, '^%d+[%]%)]?$') then -- Use the greatest badness multiplier if not badness_mult or diff --git a/test/functional/cases/105_mimetypes.robot b/test/functional/cases/105_mimetypes.robot index 49c5ffc67..54a9cb4bb 100644 --- a/test/functional/cases/105_mimetypes.robot +++ b/test/functional/cases/105_mimetypes.robot @@ -33,6 +33,16 @@ Dotted file name is followed by Bad Extension Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 Should Not Contain ${result.stdout} MIME_DOUBLE_BAD_EXTENSION +Dotted numbers in parentheses is followed by Bad Extension + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/next2last-digits_in_parens.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[msi\\]\\n re=1 + Should Not Contain ${result.stdout} MIME_DOUBLE_BAD_EXTENSION + +Dotted numbers in square brackets is followed by Bad Extension + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/next2last-digits_in_brackets.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[msi\\]\\n re=1 + Should Not Contain ${result.stdout} MIME_DOUBLE_BAD_EXTENSION + Rar4 ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 diff --git a/test/functional/messages/next2last-digits_in_brackets.eml b/test/functional/messages/next2last-digits_in_brackets.eml new file mode 100644 index 000000000..9f2783213 --- /dev/null +++ b/test/functional/messages/next2last-digits_in_brackets.eml @@ -0,0 +1,9 @@ +Content-Type: multipart/mixed; boundary="------------D6BBFC1853527FEEDD26DC71" + +--------------D6BBFC1853527FEEDD26DC71 +Content-Type: application/x-msi; name="PDF417(3.2.4).msi" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="PDF417(3.2.4).msi" + +MAo= +--------------D6BBFC1853527FEEDD26DC71-- diff --git a/test/functional/messages/next2last-digits_in_parens.eml b/test/functional/messages/next2last-digits_in_parens.eml new file mode 100644 index 000000000..efa90fa4c --- /dev/null +++ b/test/functional/messages/next2last-digits_in_parens.eml @@ -0,0 +1,9 @@ +Content-Type: multipart/mixed; boundary="------------D6BBFC1853527FEEDD26DC71" + +--------------D6BBFC1853527FEEDD26DC71 +Content-Type: application/x-msi; name="PDF417(3.2.4).msi" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="PDF417[3.2.4].msi" + +MAo= +--------------D6BBFC1853527FEEDD26DC71-- |