From: Thomas Oettli Date: Mon, 15 Apr 2019 15:34:42 +0000 (+0200) Subject: [Minor] mime_types: decode hex encoded characters X-Git-Tag: 1.9.2~9^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e20e00c8d53433507f178098c17d152d754de78;p=thirdparty%2Frspamd.git [Minor] mime_types: decode hex encoded characters in filenames to improve file extension detection --- diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index c898540c09..1141047a27 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]', '?')