···
ref := strings.TrimSuffix(file, ".tar.gz")
// This allows the browser to use a proper name for the file when
-
filename := fmt.Sprintf("%s-%s.tar.gz", name, ref)
setContentDisposition(w, filename)
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
-
gr, err := git.Open(path, ref)
···
-
prefix := fmt.Sprintf("%s-%s", name, ref)
err = gr.WriteTar(gw, prefix)
// once we start writing to the body we can't report error anymore
···
ref := strings.TrimSuffix(file, ".tar.gz")
+
unescapedRef, err := url.PathUnescape(ref)
+
safeRefFilename := strings.ReplaceAll(plumbing.ReferenceName(unescapedRef).Short(), "/", "-")
// This allows the browser to use a proper name for the file when
+
filename := fmt.Sprintf("%s-%s.tar.gz", name, safeRefFilename)
setContentDisposition(w, filename)
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
+
gr, err := git.Open(path, unescapedRef)
···
+
prefix := fmt.Sprintf("%s-%s", name, safeRefFilename)
err = gr.WriteTar(gw, prefix)
// once we start writing to the body we can't report error anymore