Properly decode \\n

This commit is contained in:
Mitchell Hashimoto 2014-11-12 21:12:45 -08:00
parent ab2c4c3120
commit 88ef419bd9
4 changed files with 7 additions and 3 deletions

View File

@ -47,7 +47,7 @@ func TestDecode_interface(t *testing.T) {
"escape.hcl",
false,
map[string]interface{}{
"foo": "bar\"baz",
"foo": "bar\"baz\\n",
},
},
{
@ -196,7 +196,7 @@ func TestDecode_interface(t *testing.T) {
}
if !reflect.DeepEqual(out, tc.Out) {
t.Fatalf("Input: %s\n\n%#v\n\n%#v", tc.File, out, tc.Out)
t.Fatalf("Input: %s\n\nActual: %#v\n\nExpected: %#v", tc.File, out, tc.Out)
}
}
}

View File

@ -365,6 +365,8 @@ func (x *hclLex) lexString(yylval *hclSymType) int {
c = n
case 'n':
c = '\n'
case '\\':
c = n
default:
x.backup()
}

View File

@ -133,6 +133,8 @@ func (x *jsonLex) lexString(yylval *jsonSymType) int {
c = n
case 'n':
c = '\n'
case '\\':
c = n
default:
x.backup()
}

View File

@ -1 +1 @@
foo = "bar\"baz"
foo = "bar\"baz\\n"