keep trailing backslash during reverse escape
This commit is contained in:
1 parent
7a4d1cc275
commit
0482340d5e
2 files changed
+5
No files matched your search
@@ -75,6 +75,9 @@ func unescape(s string) string {
|
||||
esc = false
|
||||
buf = append(buf, r)
|
||||
}
|
||||
if esc {
|
||||
buf = append(buf, '\\')
|
||||
}
|
||||
return string(buf)
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ func TestEscape(t *testing.T) {
|
||||
{`foo#bar`, `foo\#bar`},
|
||||
{`foo\tbar`, `foo\\tbar`},
|
||||
{"foo\tbar", "foo\\\tbar"},
|
||||
{`foo\`, `foo\\`},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -110,6 +111,7 @@ func TestUnescape(t *testing.T) {
|
||||
{`foo\#bar`, `foo#bar`},
|
||||
{`foo\\tbar`, `foo\tbar`},
|
||||
{"foo\\\tbar", "foo\tbar"},
|
||||
{`foo\`, `foo\`},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in new issue
Block a user