diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-02-17 10:55:42 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-02-18 09:38:37 -0700 |
commit | 024ddda123bcc1e042451f1990973291200fa090 (patch) | |
tree | cf5812921f0667c97ec846e11a4a20153090cc5f /pkg/api/handlers | |
parent | 5dacee93950a97ea14180bb86f21e462101fe5ea (diff) | |
download | podman-024ddda123bcc1e042451f1990973291200fa090.tar.gz podman-024ddda123bcc1e042451f1990973291200fa090.tar.bz2 podman-024ddda123bcc1e042451f1990973291200fa090.zip |
Update mux rules to allow slashes in image names
%2F escaping is also supported.
Return better response on bad search terms
Fixes #5229
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/images.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/utils/images.go | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/pkg/api/handlers/images.go b/pkg/api/handlers/images.go index cd3c0b93f..e4e394d68 100644 --- a/pkg/api/handlers/images.go +++ b/pkg/api/handlers/images.go @@ -155,7 +155,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { } results, err := image.SearchImages(query.Term, options) if err != nil { - utils.InternalServerError(w, err) + utils.BadRequest(w, "term", query.Term, err) } utils.WriteResponse(w, http.StatusOK, results) } diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go index d0dfbf3ab..f68a71561 100644 --- a/pkg/api/handlers/utils/images.go +++ b/pkg/api/handlers/utils/images.go @@ -31,12 +31,16 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) { if _, found := mux.Vars(r)["digests"]; found && query.Digests { UnSupportedParameter("digests") } + if len(query.Filters) > 0 { for k, v := range query.Filters { for _, val := range v { filters = append(filters, fmt.Sprintf("%s=%s", k, val)) } } + return runtime.ImageRuntime().GetImagesWithFilters(filters) + } else { + return runtime.ImageRuntime().GetImages() } - return runtime.ImageRuntime().GetImagesWithFilters(filters) + } |