[#134] Support percent-encoding
All checks were successful
/ DCO (pull_request) Successful in 1m10s
/ Vulncheck (pull_request) Successful in 1m28s
/ Builds (pull_request) Successful in 1m7s
/ Lint (pull_request) Successful in 2m9s
/ Tests (pull_request) Successful in 55s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2024-10-18 12:13:44 +03:00
parent ccabd8ac40
commit 8ae81ba0f1
2 changed files with 8 additions and 1 deletions

View file

@ -5,6 +5,7 @@ This document outlines major changes between releases.
## [Unreleased]
## [0.30.2] - 2024-09-03
- Support percent-encoding for GET queries (#134)
### Added
- Fuzzing tests (#135)

View file

@ -195,6 +195,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)
@ -203,7 +209,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)