diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-07-27 09:59:00 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-07-27 15:33:24 +0200 |
commit | 1a1f9fac06496c6414d1dc57090962b57f6eff6c (patch) | |
tree | 89e8ea273f4fd0e3a1b36e5dbf994257c7a69354 | |
parent | 9352c342d62bbf3b49b0d4d67e8704cbbcd212cd (diff) | |
download | podman-1a1f9fac06496c6414d1dc57090962b57f6eff6c.tar.gz podman-1a1f9fac06496c6414d1dc57090962b57f6eff6c.tar.bz2 podman-1a1f9fac06496c6414d1dc57090962b57f6eff6c.zip |
API events: fix parsing error
Fix an error where an absent "filters" parameter led to JSON parsing
errors.
Fixes: #7078
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
-rw-r--r-- | pkg/api/handlers/compat/events.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go index 9d5cb5045..8c4ad575b 100644 --- a/pkg/api/handlers/compat/events.go +++ b/pkg/api/handlers/compat/events.go @@ -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 { |