hcl: multi-line comments aren't allowed to terminate with EOF
This commit is contained in:
parent
0be569fb26
commit
5486421143
@ -196,6 +196,12 @@ func TestDecode_interface(t *testing.T) {
|
|||||||
"bar": "value",
|
"bar": "value",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"unterminated_block_comment.hcl",
|
||||||
|
true,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
@ -125,7 +125,14 @@ func (x *hclLex) consumeComment(c rune) bool {
|
|||||||
c = x.next()
|
c = x.next()
|
||||||
if c == lexEOF {
|
if c == lexEOF {
|
||||||
x.backup()
|
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'
|
// Single line comments continue until a '\n'
|
||||||
|
2
test-fixtures/unterminated_block_comment.hcl
Normal file
2
test-fixtures/unterminated_block_comment.hcl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/*
|
||||||
|
Foo
|
Loading…
Reference in New Issue
Block a user