commit 0e20e00: [Minor] mime_types: decode hex encoded characters in filenames to improve file extension detection

Thomas Oettli spacefreak at noop.ch
Tue Apr 16 11:14:13 UTC 2019


Author: Thomas Oettli
Date: 2019-04-15 17:34:42 +0200
URL: https://github.com/rspamd/rspamd/commit/0e20e00c8d53433507f178098c17d152d754de78

[Minor] mime_types: decode hex encoded characters in filenames to improve file extension detection

---
 src/plugins/lua/mime_types.lua | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index c898540c0..1141047a2 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]', '?')
 


More information about the Commits mailing list