Unverified Commit 474e38ee authored by hc-github-team-secure-vault-core's avatar hc-github-team-secure-vault-core Committed by GitHub
Browse files

Backport of fix TypeCommaIntSlice panic caused by json.Number input into release/1.10.x (#15082)


* backport of commit df9416d64cf103a3da4e484cac2ce428a1c82a95

* backport of commit 8edb1c24505584230c71708f31be7cd7f392142d
Co-authored-by: default avatarChris Capurso <1036769+ccapurso@users.noreply.github.com>
parent 594d1e83
Showing with 22 additions and 0 deletions
+22 -0
```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},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment