diff --git a/decoder_test.go b/decoder_test.go index ab19457..23ab851 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -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) } } } diff --git a/hcl/lex.go b/hcl/lex.go index 6dfa8fe..1d2e077 100644 --- a/hcl/lex.go +++ b/hcl/lex.go @@ -365,6 +365,8 @@ func (x *hclLex) lexString(yylval *hclSymType) int { c = n case 'n': c = '\n' + case '\\': + c = n default: x.backup() } diff --git a/json/lex.go b/json/lex.go index f9be208..aa4f7c3 100644 --- a/json/lex.go +++ b/json/lex.go @@ -133,6 +133,8 @@ func (x *jsonLex) lexString(yylval *jsonSymType) int { c = n case 'n': c = '\n' + case '\\': + c = n default: x.backup() } diff --git a/test-fixtures/escape.hcl b/test-fixtures/escape.hcl index 7f9a566..ead1b8b 100644 --- a/test-fixtures/escape.hcl +++ b/test-fixtures/escape.hcl @@ -1 +1 @@ -foo = "bar\"baz" +foo = "bar\"baz\\n"