diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-09-23 10:41:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-09-23 10:41:16 -0300 |
commit | a1089b415a3f5c753aa1b40758ffdaf28d5701b0 (patch) | |
tree | c2bc42dd8b83e33d3159e6cc7f28daa2d2204b53 /testes/utf8.lua | |
parent | f8c4c4fcf2b2fed00b3c5b71c19cd64e539dee51 (diff) | |
download | lua-github-a1089b415a3f5c753aa1b40758ffdaf28d5701b0.tar.gz |
Bug: 'utf8.codes' accepts spurious continuation bytes
Diffstat (limited to 'testes/utf8.lua')
-rw-r--r-- | testes/utf8.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/testes/utf8.lua b/testes/utf8.lua index 461e223c..7472cfd0 100644 --- a/testes/utf8.lua +++ b/testes/utf8.lua @@ -97,9 +97,15 @@ do -- error indication in utf8.len assert(not a and b == p) end check("abc\xE3def", 4) - check("汉字\x80", #("汉字") + 1) check("\xF4\x9F\xBF", 1) check("\xF4\x9F\xBF\xBF", 1) + -- spurious continuation bytes + check("汉字\x80", #("汉字") + 1) + check("\x80hello", 1) + check("hel\x80lo", 4) + check("汉字\xBF", #("汉字") + 1) + check("\xBFhello", 1) + check("hel\xBFlo", 4) end -- errors in utf8.codes @@ -112,12 +118,16 @@ do end errorcodes("ab\xff") errorcodes("\u{110000}") + errorcodes("in\x80valid") + errorcodes("\xbfinvalid") + errorcodes("αλφ\xBFα") -- calling interation function with invalid arguments local f = utf8.codes("") assert(f("", 2) == nil) assert(f("", -1) == nil) assert(f("", math.mininteger) == nil) + end -- error in initial position for offset |