parser: Fix missing check for upper exponent (#665)

This commit is contained in:
Cameron Moore
2021-11-09 20:15:23 -06:00
committed by GitHub
parent f27a07d31a
commit 2dbd29a565
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -968,7 +968,7 @@ byteLoop:
func (p *parser) scanIntOrFloat(b []byte) (ast.Reference, []byte, error) {
i := 0
if len(b) > 2 && b[0] == '0' && b[1] != '.' && b[1] != 'e' {
if len(b) > 2 && b[0] == '0' && b[1] != '.' && b[1] != 'e' && b[1] != 'E' {
var isValidRune validRuneFn
switch b[1] {
+5
View File
@@ -155,6 +155,11 @@ func TestUnmarshal_Floats(t *testing.T) {
input: `0e0`,
expected: 0.0,
},
{
desc: "float upper exponent zero",
input: `0E0`,
expected: 0.0,
},
{
desc: "float fractional with exponent",
input: `6.626e-34`,