diff --git a/CHANGELOG.md b/CHANGELOG.md index b322c96..a489027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ This document outlines major changes between releases. ## [Unreleased] +- Support percent-encoding for GET queries (#134) ### Changed - Update go version to 1.22 (#132) diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 0bbcdb9..4de9d9a 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -215,6 +215,12 @@ func (h *Handler) byObjectName(req *fasthttp.RequestCtx, f func(context.Context, log = h.log.With(zap.String("bucketname", bucketname), zap.String("key", key)) ) + unescapedKey, err := url.QueryUnescape(key) + if err != nil { + logAndSendBucketError(req, log, err) + return + } + ctx := utils.GetContextFromRequest(req) bktInfo, err := h.getBucketInfo(ctx, bucketname, log) @@ -223,7 +229,7 @@ func (h *Handler) byObjectName(req *fasthttp.RequestCtx, f func(context.Context, return } - foundOid, err := h.tree.GetLatestVersion(ctx, &bktInfo.CID, key) + foundOid, err := h.tree.GetLatestVersion(ctx, &bktInfo.CID, unescapedKey) if err != nil { if errors.Is(err, tree.ErrNodeAccessDenied) { response.Error(req, "Access Denied", fasthttp.StatusForbidden)