From: Vsevolod Stakhov Date: Fri, 30 Oct 2020 18:17:44 +0000 (+0000) Subject: [Minor] Lua_mime: Some more issue fixed X-Git-Tag: 2.7~183 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab791a5622c0ad6dc5d47bc2a858813b12f005fa;p=thirdparty%2Frspamd.git [Minor] Lua_mime: Some more issue fixed --- diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua index 76e3c61958..0019d7622c 100644 --- a/lualib/lua_mime.lua +++ b/lualib/lua_mime.lua @@ -340,8 +340,8 @@ local function do_replacement (task, part, mp, replacements, end -- Off-by one: match returns 0 based positions while we use 1 based in Lua for _,m in ipairs(matches_flattened) do - m[1][1] = m[1][1] - 1 - m[1][2] = m[1][2] - 1 + m[1][1] = m[1][1] + 1 + m[1][2] = m[1][2] + 1 end -- Now flattened match table is sorted by start pos and has the maximum overlapped pattern @@ -353,8 +353,8 @@ local function do_replacement (task, part, mp, replacements, local cur_start = 1 local fragments = {} for _,m in ipairs(matches_flattened) do - if m[1][1] > cur_start then - fragments[#fragments + 1] = content:sub(cur_start, m[1][1]) + if m[1][1] >= cur_start then + fragments[#fragments + 1] = content:sub(cur_start, m[1][1] - 1) fragments[#fragments + 1] = replacements[m[2]] cur_start = m[1][2] + 1 -- end of match end