diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-16 12:08:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-16 12:08:43 +0100 |
commit | 51746c82755e2d180ab9b6bcce38e977032ec737 (patch) | |
tree | 3b695a0d3c169462ab112b54b4969ccfc799fbf5 /src | |
parent | ea39656807030586d81385736c2069a704533c53 (diff) | |
parent | 0165255b168b4a55056f533f9c761b36cceb29b6 (diff) | |
download | rspamd-51746c82755e2d180ab9b6bcce38e977032ec737.tar.gz rspamd-51746c82755e2d180ab9b6bcce38e977032ec737.zip |
Merge pull request #2852 from spacefreak86/mime_types
[Minor] Improve mime_types plugin
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/mime_types.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index c898540c0..e621b5666 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -851,6 +851,9 @@ local function check_mime_type(task) fname:sub(1, ch_pos))) end + -- Decode hex encoded characters + fname = string.gsub(fname, '%%(%x%x)', function (hex) return string.char(tonumber(hex,16)) end ) + -- Replace potentially bad characters with '?' fname = fname:gsub('[^%s%g]', '?') @@ -1083,13 +1086,12 @@ local function check_mime_type(task) end if map then - local v + local v = map:get_key(ct) local detected_different = false if detected_ct and detected_ct ~= ct then - v = map:get_key(detected_ct) + local v_detected = map:get_key(detected_ct) + if v_detected > v then v = v_detected end detected_different = true - else - v = map:get_key(ct) end if v then local n = tonumber(v) |