From 218999dff899872fb38d3c8889d5bc27cc600ed1 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Fri, 10 Sep 2021 14:55:04 +0200 Subject: [PATCH] Avoid bug when replacement stop at end of string Detect when we are past the end of the string to avoid by checking if byte is not nil. Fix #510. --- data/core/regex.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/core/regex.lua b/data/core/regex.lua index 19306e0..69203cb 100644 --- a/data/core/regex.lua +++ b/data/core/regex.lua @@ -23,7 +23,7 @@ end -- Moves to the end of the identified character. local function end_character(str, index) local byte = string.byte(str, index + 1) - while byte >= 128 and byte < 192 do + while byte and byte >= 128 and byte < 192 do index = index + 1 byte = string.byte(str, index + 1) end