keep trailing backslash during reverse escape

This commit is contained in:
Gokcehan committed 2019-10-25 20:50:00 +03:00
1 parent 7a4d1cc275
commit 0482340d5e
2 files changed
+5

No files matched your search

+3
View File
@@ -75,6 +75,9 @@ func unescape(s string) string {
esc = false
buf = append(buf, r)
}
if esc {
buf = append(buf, '\\')
}
return string(buf)
}
+2
View File
@@ -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 {