function validatorlib.utf8_len(s)
local c, j=0, 1
while j <= #s do
local cb = str_byte(s, j)
if cb >= 0 and cb <= 127 then j = j + 1
elseif cb >= 192 and cb <= 223 then j = j + 2
elseif cb >= 224 and cb <= 239 then j = j + 3
elseif cb >= 240 and cb <= 247 then j = j + 4
end
c = c + 1
end
return c
end
input "%ff", after urldecode ,str_byte(s,j), when cb > 247,#s = 1, j = 1 , will cause endless loop
function validatorlib.utf8_len(s) local c, j=0, 1 while j <= #s do local cb = str_byte(s, j) if cb >= 0 and cb <= 127 then j = j + 1 elseif cb >= 192 and cb <= 223 then j = j + 2 elseif cb >= 224 and cb <= 239 then j = j + 3 elseif cb >= 240 and cb <= 247 then j = j + 4 end c = c + 1 end return c end
input "%ff", after urldecode ,str_byte(s,j), when cb > 247,#s = 1, j = 1 , will cause endless loop