Skip to content

Commit dc731c9

Browse files
committed
improvements
1 parent 20d8d6e commit dc731c9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

routers/web/repo/githttp.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"net/http"
1212
"os"
13+
"path"
1314
"regexp"
1415
"slices"
1516
"strconv"
@@ -379,7 +380,7 @@ func (h *serviceHandler) sendFile(ctx *context.Context, contentType, file string
379380
}
380381

381382
fs := gitrepo.GetRepoFS(h.getStorageRepo())
382-
f, err := fs.Open(file)
383+
f, err := fs.Open(path.Clean(file))
383384
if err != nil {
384385
if os.IsNotExist(err) {
385386
ctx.Resp.WriteHeader(http.StatusNotFound)
@@ -442,6 +443,7 @@ func serviceRPC(ctx *context.Context, h *serviceHandler, service string) {
442443
ctx.Resp.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", service))
443444

444445
reqBody := ctx.Req.Body
446+
445447
// Handle GZIP.
446448
if ctx.Req.Header.Get("Content-Encoding") == "gzip" {
447449
reqBody, err = gzip.NewReader(reqBody)
@@ -525,7 +527,6 @@ func GetInfoRefs(ctx *context.Context) {
525527
if protocol := ctx.Req.Header.Get("Git-Protocol"); protocol != "" && safeGitProtocolHeader.MatchString(protocol) {
526528
h.environ = append(h.environ, "GIT_PROTOCOL="+protocol)
527529
}
528-
529530
h.environ = append(os.Environ(), h.environ...)
530531

531532
refs, _, err := gitrepo.RunCmdBytes(ctx, h.getStorageRepo(), cmd.AddArguments("--stateless-rpc", "--advertise-refs", ".").

0 commit comments

Comments
 (0)