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:
commit
7cb7455c28
@ -379,6 +379,12 @@ func TestDecode_interface(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"git_crypt.hcl",
|
||||||
|
true,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
@ -504,6 +504,10 @@ func TestParse(t *testing.T) {
|
|||||||
"object_key_assign_without_value3.hcl",
|
"object_key_assign_without_value3.hcl",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"git_crypt.hcl",
|
||||||
|
true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixtureDir = "./test-fixtures"
|
const fixtureDir = "./test-fixtures"
|
||||||
|
BIN
hcl/parser/test-fixtures/git_crypt.hcl
Normal file
BIN
hcl/parser/test-fixtures/git_crypt.hcl
Normal file
Binary file not shown.
@ -95,6 +95,12 @@ func (s *Scanner) next() rune {
|
|||||||
s.srcPos.Column = 0
|
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
|
// debug
|
||||||
// fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column)
|
// fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column)
|
||||||
return ch
|
return ch
|
||||||
|
BIN
test-fixtures/git_crypt.hcl
Normal file
BIN
test-fixtures/git_crypt.hcl
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user