mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
fix TypeCommaIntSlice panic caused by json.Number input (#15072)
* fix TypeCommaIntSlice panic caused by json.Number input * add changelog entry
This commit is contained in:
3
changelog/15072.txt
Normal file
3
changelog/15072.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
core: Fix panic caused by parsing JSON integers for fields defined as comma-delimited integers
|
||||
```
|
||||
@@ -243,6 +243,12 @@ func (d *FieldData) getPrimitive(k string, schema *FieldSchema) (interface{}, bo
|
||||
|
||||
case TypeCommaIntSlice:
|
||||
var result []int
|
||||
|
||||
jsonIn, ok := raw.(json.Number)
|
||||
if ok {
|
||||
raw = jsonIn.String()
|
||||
}
|
||||
|
||||
config := &mapstructure.DecoderConfig{
|
||||
Result: &result,
|
||||
WeaklyTypedInput: true,
|
||||
|
||||
@@ -593,6 +593,19 @@ func TestFieldDataGet(t *testing.T) {
|
||||
[]int{},
|
||||
false,
|
||||
},
|
||||
|
||||
"comma int slice type, json number": {
|
||||
map[string]*FieldSchema{
|
||||
"foo": {Type: TypeCommaIntSlice},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"foo": json.Number("1"),
|
||||
},
|
||||
"foo",
|
||||
[]int{1},
|
||||
false,
|
||||
},
|
||||
|
||||
"name string type, valid string": {
|
||||
map[string]*FieldSchema{
|
||||
"foo": {Type: TypeNameString},
|
||||
|
||||
Reference in New Issue
Block a user