fix: limit octal escapes in double quotes to three digits (#2725)
The scanner consumed every digit following a backslash as part of an octal escape. A digit right after an escape was therefore swallowed: "\0337" (ESC 7) became the single byte 0o337 instead of ESC followed by "7", and "\0338" (ESC 8) failed to parse and became a NUL byte. Stop after three digits, as in C and other languages with octal string escapes. Escapes of up to three digits are read as before. Co-authored-by: ybai08 <271969568+ybai08@users.noreply.github.com>
This commit is contained in:
1 parent
5298e8813b
commit
91e269fe5c
2 files changed
+15
-1
No files matched your search
@@ -84,6 +84,18 @@ var gEvalTests = []struct {
|
||||
[]expr{&callExpr{"echo", []string{"hello\101world"}, 1}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo "hello\1011world"`,
|
||||
[]string{"echo", "hello\1011world", "\n"},
|
||||
[]expr{&callExpr{"echo", []string{"hello\1011world"}, 1}},
|
||||
},
|
||||
|
||||
{
|
||||
`tty-write "\0337\0338"`,
|
||||
[]string{"tty-write", "\0337\0338", "\n"},
|
||||
[]expr{&callExpr{"tty-write", []string{"\0337\0338"}, 1}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\ world`,
|
||||
[]string{"echo", "hello world", "\n"},
|
||||
|
||||
Reference in new issue
Block a user