Merge pull request #170 from hashicorp/b-null

hcl: error if we scan a null char before end of input text
This commit is contained in:
Mitchell Hashimoto 2016-11-21 18:11:24 -08:00 committed by GitHub
commit 7cb7455c28
5 changed files with 16 additions and 0 deletions

View File

@ -379,6 +379,12 @@ func TestDecode_interface(t *testing.T) {
},
},
},
{
"git_crypt.hcl",
true,
nil,
},
}
for _, tc := range cases {

View File

@ -504,6 +504,10 @@ func TestParse(t *testing.T) {
"object_key_assign_without_value3.hcl",
true,
},
{
"git_crypt.hcl",
true,
},
}
const fixtureDir = "./test-fixtures"

Binary file not shown.

View File

@ -95,6 +95,12 @@ func (s *Scanner) next() rune {
s.srcPos.Column = 0
}
// If we see a null character with data left, then that is an error
if ch == '\x00' && s.buf.Len() > 0 {
s.err("unexpected null character (0x00)")
return eof
}
// debug
// fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column)
return ch

BIN
test-fixtures/git_crypt.hcl Normal file

Binary file not shown.