mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 22:55:29 +00:00
Do not stay in the escape state after a backslash-newline in StringLiteral
The empty case '\n' in the backslash state was meant to drop a backslash-newline pair like Python's python_string does, but it never reset the state, so the next character was parsed as an escape.
This commit is contained in:
parent
c73326a9d8
commit
632265ec33
2 changed files with 3 additions and 0 deletions
|
|
@ -121,6 +121,7 @@ func StringLiteral(val string) (string, error) {
|
|||
case backslash:
|
||||
switch ch {
|
||||
case '\n':
|
||||
state = normal
|
||||
case '\\':
|
||||
ans.WriteRune('\\')
|
||||
state = normal
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ func TestStringLiteralParsing(t *testing.T) {
|
|||
`abc`: `abc`,
|
||||
`a\nb\M`: "a\nb\\M",
|
||||
`a\x20\x1\u1234\123\12|`: "a \\x1\u1234\123\x0a|",
|
||||
"a\\\nnb": "anb",
|
||||
"a\\\n\\tb": "a\tb",
|
||||
} {
|
||||
actual, err := StringLiteral(q)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue