fix: validate closing quote in HexOrDecimal64.UnmarshalJSON

This commit is contained in:
Adam 2025-12-10 18:00:51 +01:00 committed by GitHub
parent b98b255449
commit 3830fa0c93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,7 +30,7 @@ type HexOrDecimal64 uint64
// It is similar to UnmarshalText, but allows parsing real decimals too, not just // It is similar to UnmarshalText, but allows parsing real decimals too, not just
// quoted decimal strings. // quoted decimal strings.
func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error { func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error {
if len(input) > 1 && input[0] == '"' { if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' {
input = input[1 : len(input)-1] input = input[1 : len(input)-1]
} }
return i.UnmarshalText(input) return i.UnmarshalText(input)