diff --git a/misc.go b/misc.go index eea86dc9..14e23164 100644 --- a/misc.go +++ b/misc.go @@ -75,6 +75,9 @@ func unescape(s string) string { esc = false buf = append(buf, r) } + if esc { + buf = append(buf, '\\') + } return string(buf) } diff --git a/misc_test.go b/misc_test.go index a3833011..920f99a7 100644 --- a/misc_test.go +++ b/misc_test.go @@ -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 {