Skip to content

Commit

Permalink
httptransport: Check MediaType can be split on /
Browse files Browse the repository at this point in the history
It is possible for a client to manifest a panic by sending
invalid Accept header.

Signed-off-by: crozzy <[email protected]>
  • Loading branch information
crozzy committed Dec 8, 2023
1 parent 0be08ec commit b57e664
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions httptransport/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func pickContentType(w http.ResponseWriter, r *http.Request, allow []string) err
a.Q, _ = strconv.ParseFloat(qs, 64)
}
typ := strings.Split(mt, "/")
if len(typ) != 2 {
return fmt.Errorf("malformed Accept value %s", mt)
}
a.Type = typ[0]
a.Subtype = typ[1]
acceptable = append(acceptable, a)
Expand Down

0 comments on commit b57e664

Please sign in to comment.