From 5ee35ca783d55711793bdd1a101205049d08f4c8 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 27 Jul 2020 09:59:00 +0200 Subject: 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 --- pkg/api/handlers/compat/events.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg/api/handlers/compat') 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 { -- cgit v1.2.3-54-g00ecf