mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 12:20:03 +08:00
commands: Safer type coercion when choosing marshaller
This commit is contained in:

committed by
Juan Batiz-Benet

parent
0149f65c6c
commit
33ad56e6d0
@ -120,11 +120,12 @@ func (r *response) Marshal() ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
enc, ok := r.req.Option(EncShort)
|
||||
if !ok || enc.(string) == "" {
|
||||
enc, found := r.req.Option(EncShort)
|
||||
encStr, ok := enc.(string)
|
||||
if !found || !ok || encStr == "" {
|
||||
return nil, fmt.Errorf("No encoding type was specified")
|
||||
}
|
||||
encType := EncodingType(strings.ToLower(enc.(string)))
|
||||
encType := EncodingType(strings.ToLower(encStr))
|
||||
|
||||
marshaller, ok := marshallers[encType]
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user