hcl: multi-line comments aren't allowed to terminate with EOF

This commit is contained in:
Mitchell Hashimoto 2015-06-23 21:38:11 -07:00
parent 0be569fb26
commit 5486421143
3 changed files with 16 additions and 1 deletions

View File

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

View File

@ -125,7 +125,14 @@ func (x *hclLex) consumeComment(c rune) bool {
c = x.next()
if c == lexEOF {
x.backup()
return true
if single {
// Single line comments can end with an EOF
return true
}
// Multi-line comments must end with a */
x.createErr(fmt.Sprintf("end of multi-line comment expected, got EOF"))
return false
}
// Single line comments continue until a '\n'

View File

@ -0,0 +1,2 @@
/*
Foo