add check to prevent bad unicode from crashing the server

This commit is contained in:
flux 2019-07-06 02:17:06 +00:00 committed by Vanessa Dannenberg
parent da1deecb4c
commit db78e3dcdb

@ -128,7 +128,12 @@ local make_iso = function(s)
local s2 = "" local s2 = ""
while i <= string.len(s) do while i <= string.len(s) do
if string.byte(s,i) > 159 then if string.byte(s,i) > 159 then
s2 = s2..string.char(get_iso(string.sub(s, i, i+1))) local ciso = get_iso(string.sub(s, i, i+1))
if ciso >= 0 and ciso < 256 then
s2 = s2..string.char(ciso)
else
s2 = s2..string.char(127)
end
i = i + 2 i = i + 2
else else
s2 = s2..string.sub(s, i, i) s2 = s2..string.sub(s, i, i)