From 48473843aced0d7d5674eaaebd6c033b6eac1432 Mon Sep 17 00:00:00 2001
From: Pavel Pogodaev
Date: Mon, 26 Aug 2024 18:47:33 +0300
Subject: [PATCH] [#134] Support percent-encoding
Signed-off-by: Pavel Pogodaev
(cherry picked from commit 843708a558c5b9f308c8eafeaa09171a45500202)
---
CHANGELOG.md | 1 +
internal/handler/handler.go | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04b60f6..1ca9b83 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)
## [0.30.2] - 2024-09-03
diff --git a/internal/handler/handler.go b/internal/handler/handler.go
index 197649e..62b4e1c 100644
--- a/internal/handler/handler.go
+++ b/internal/handler/handler.go
@@ -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)