Skip to content

Commit 0f3cb5d

Browse files
committed
http: add QueryUnescape in HTTPPool.ServeHTTP
Use url.QueryUnescape to inverse escaped group and key in path.
1 parent 84a468c commit 0f3cb5d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

http.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,16 @@ func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {
148148
http.Error(w, "bad request", http.StatusBadRequest)
149149
return
150150
}
151-
groupName := parts[0]
152-
key := parts[1]
151+
groupName, err := url.QueryUnescape(parts[0])
152+
if err != nil {
153+
http.Error(w, "bad request", http.StatusBadRequest)
154+
return
155+
}
156+
key, err := url.QueryUnescape(parts[1])
157+
if err != nil {
158+
http.Error(w, "bad request", http.StatusBadRequest)
159+
return
160+
}
153161

154162
// Fetch the value for this group/key.
155163
group := GetGroup(groupName)
@@ -164,7 +172,7 @@ func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {
164172

165173
group.Stats.ServerRequests.Add(1)
166174
var value []byte
167-
err := group.Get(ctx, key, AllocatingByteSliceSink(&value))
175+
err = group.Get(ctx, key, AllocatingByteSliceSink(&value))
168176
if err != nil {
169177
http.Error(w, err.Error(), http.StatusInternalServerError)
170178
return

0 commit comments

Comments
 (0)