From ce7924d7fdfccc0d78cd76488972578ce01a3bc7 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Wed, 8 May 2019 12:15:17 +0200 Subject: [PATCH] runservice: use the path escaped cache key Use the path escaped cache key so we can also handle cache keys with slashes inside. --- internal/services/runservice/api/executor.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/internal/services/runservice/api/executor.go b/internal/services/runservice/api/executor.go index 5b28b6a..fa126d1 100644 --- a/internal/services/runservice/api/executor.go +++ b/internal/services/runservice/api/executor.go @@ -20,7 +20,6 @@ import ( "encoding/json" "io" "net/http" - "net/url" "strconv" "github.com/gorilla/mux" @@ -273,11 +272,9 @@ func NewCacheHandler(logger *zap.Logger, ost *objectstorage.ObjStorage) *CacheHa func (h *CacheHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) // TODO(sgotti) Check authorized call from executors - key, err := url.PathUnescape(vars["key"]) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } + + // keep and use the escaped path + key := vars["key"] if key == "" { http.Error(w, "empty cache key", http.StatusBadRequest) return @@ -384,11 +381,9 @@ func NewCacheCreateHandler(logger *zap.Logger, ost *objectstorage.ObjStorage) *C func (h *CacheCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) // TODO(sgotti) Check authorized call from executors - key, err := url.PathUnescape(vars["key"]) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } + + // keep and use the escaped path + key := vars["key"] if key == "" { http.Error(w, "empty cache key", http.StatusBadRequest) return