Monorepo for Tangled tangled.org

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
··· 165 166 func StripLeadingAt(next http.Handler) http.Handler { 167 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 168 - path := req.URL.Path 169 if strings.HasPrefix(path, "/@") { 170 - req.URL.Path = "/" + strings.TrimPrefix(path, "/@") 171 } 172 next.ServeHTTP(w, req) 173 })
··· 165 166 func StripLeadingAt(next http.Handler) http.Handler { 167 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 168 + path := req.URL.EscapedPath() 169 if strings.HasPrefix(path, "/@") { 170 + req.URL.RawPath = "/" + strings.TrimPrefix(path, "/@") 171 } 172 next.ServeHTTP(w, req) 173 })
+3
knotserver/routes.go
··· 10 "fmt" 11 "log" 12 "net/http" 13 "os" 14 "path/filepath" 15 "strconv" ··· 34 path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r)) 35 l := h.l.With("path", path, "handler", "RepoIndex") 36 ref := chi.URLParam(r, "ref") 37 38 gr, err := git.Open(path, ref) 39 if err != nil { ··· 148 func (h *Handle) RepoTree(w http.ResponseWriter, r *http.Request) { 149 treePath := chi.URLParam(r, "*") 150 ref := chi.URLParam(r, "ref") 151 152 l := h.l.With("handler", "RepoTree", "ref", ref, "treePath", treePath) 153
··· 10 "fmt" 11 "log" 12 "net/http" 13 + "net/url" 14 "os" 15 "path/filepath" 16 "strconv" ··· 35 path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r)) 36 l := h.l.With("path", path, "handler", "RepoIndex") 37 ref := chi.URLParam(r, "ref") 38 + ref, _ = url.PathUnescape(ref) 39 40 gr, err := git.Open(path, ref) 41 if err != nil { ··· 150 func (h *Handle) RepoTree(w http.ResponseWriter, r *http.Request) { 151 treePath := chi.URLParam(r, "*") 152 ref := chi.URLParam(r, "ref") 153 + ref, _ = url.PathUnescape(ref) 154 155 l := h.l.With("handler", "RepoTree", "ref", ref, "treePath", treePath) 156