commit ab791a5: [Minor] Lua_mime: Some more issue fixed

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Oct 30 18:21:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-10-30 18:17:44 +0000
URL: https://github.com/rspamd/rspamd/commit/ab791a5622c0ad6dc5d47bc2a858813b12f005fa (HEAD -> master)

[Minor] Lua_mime: Some more issue fixed

---
 lualib/lua_mime.lua | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index 76e3c6195..0019d7622 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


More information about the Commits mailing list