1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 13:22:58 +03:00

yaml,fuzz: gojq.Normalize value to fix type panic

This commit is contained in:
Mattias Wadman 2022-10-11 18:45:09 +02:00
parent a49fe00898
commit 2606916753
3 changed files with 7 additions and 2 deletions

5
format/yaml/testdata/normalize.fqtest vendored Normal file
View File

@ -0,0 +1,5 @@
# normalize uint64 to bigint
$ fq -n '"[18446744073709551615]" | yaml'
[
18446744073709551615
]

View File

@ -45,7 +45,7 @@ func decodeYAML(d *decode.D, _ any) any {
}
var s scalar.S
s.Actual = r
s.Actual = gojqex.Normalize(r)
switch s.Actual.(type) {
case map[string]any,

View File

@ -1126,7 +1126,7 @@ func (i *Interp) NewColorJSON(opts Options) (*colorjson.Encoder, error) {
if v, ok := toValue(func() Options { return opts }, v); ok {
return v
}
panic(fmt.Sprintf("toValue not a JQValue value: %#v", v))
panic(fmt.Sprintf("toValue not a JQValue value: %#v (%T)", v, v))
},
colorjson.Colors{
Reset: []byte(ansi.Reset.SetString),