forked from tangled.org/core
this repo has no description

fix routing into tags/branches with slashes in them

path-extractor in the router should use an escaped path

Tangled efc021ee 3e435660

Changed files
+5 -2
appview
knotserver
+2 -2
appview/state/middleware.go
···
func StripLeadingAt(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
-
path := req.URL.Path
+
path := req.URL.EscapedPath()
if strings.HasPrefix(path, "/@") {
-
req.URL.Path = "/" + strings.TrimPrefix(path, "/@")
+
req.URL.RawPath = "/" + strings.TrimPrefix(path, "/@")
}
next.ServeHTTP(w, req)
})
+3
knotserver/routes.go
···
"fmt"
"log"
"net/http"
+
"net/url"
"os"
"path/filepath"
"strconv"
···
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
l := h.l.With("path", path, "handler", "RepoIndex")
ref := chi.URLParam(r, "ref")
+
ref, _ = url.PathUnescape(ref)
gr, err := git.Open(path, ref)
if err != nil {
···
func (h *Handle) RepoTree(w http.ResponseWriter, r *http.Request) {
treePath := chi.URLParam(r, "*")
ref := chi.URLParam(r, "ref")
+
ref, _ = url.PathUnescape(ref)
l := h.l.With("handler", "RepoTree", "ref", ref, "treePath", treePath)