Skip to content

Commit

Permalink
API events: fix parsing error
Browse files Browse the repository at this point in the history
Fix an error where an absent "filters" parameter led to JSON parsing
errors.

Fixes: containers#7078
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 27, 2020
1 parent 11e8e65 commit 5ee35ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/api/handlers/compat/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ func filtersFromRequest(r *http.Request) ([]string, error) {
compatFilters map[string]map[string]bool
filters map[string][]string
libpodFilters []string
raw []byte
)
raw := []byte(r.Form.Get("filters"))

if _, found := r.URL.Query()["filters"]; found {
raw = []byte(r.Form.Get("filters"))
} else {
return []string{}, nil
}

// Backwards compat with older versions of Docker.
if err := json.Unmarshal(raw, &compatFilters); err == nil {
Expand Down

0 comments on commit 5ee35ca

Please sign in to comment.