I found this bug in string.match/gmatch/gsub handling of NUL bytes (0x00) in
the pattern string. The behavior is the same on LuaJIT 2.0.5 and 2.1.0-beta3:
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse
print(string.match("xxx", "xxx\0"))xxx
print(string.gsub("xxx\0xxx", "\0", "<NUL>"))<NUL>x<NUL>x<NUL>x<NUL><NUL>x<NUL>x<NUL>x<NUL> 8
print(string.match("xxx", "[^\0]*"))stdin:1: malformed pattern (missing ']')
print(string.match("xxx", "xxx\0"))nil
print(string.gsub("xxx\0xxx", "\0", "<NUL>"))xxx<NUL>xxx 1
print(string.match("xxx", "[^\0]*"))xxx
Attachment:
signature.asc
Description: Message signed with OpenPGP