Skip to content

Commit d02e4bd

Browse files
committed
Made ParseBoolean more robust
(It's not a performance-critical function so I think this should be fine.)
1 parent 27f1a38 commit d02e4bd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ func GetBoolean(data []byte, keys ...string) (val bool, err error) {
449449

450450
// ParseBoolean parses a Boolean ValueType into a Go bool (not particularly useful, but here for completeness)
451451
func ParseBoolean(b []byte) (bool, error) {
452-
switch b[0] {
453-
case 't':
452+
switch {
453+
case bytes.Equal(b, trueLiteral):
454454
return true, nil
455-
case 'f':
455+
case bytes.Equal(b, falseLiteral):
456456
return false, nil
457457
default:
458458
return false, MalformedValueError

0 commit comments

Comments
 (0)