fix: archive contains parent path on Windows

pull/1321/head
Ramires Viana 2021-03-09 15:54:54 +00:00
parent fc5506179a
commit 54f35701a2
1 changed files with 2 additions and 4 deletions

View File

@ -108,8 +108,6 @@ var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data)
})
func addFile(ar archiver.Writer, d *data, path, commonPath string) error {
// Checks are always done with paths with "/" as path separator.
path = strings.Replace(path, "\\", "/", -1)
if !d.Check(path) {
return nil
}
@ -134,7 +132,7 @@ func addFile(ar archiver.Writer, d *data, path, commonPath string) error {
if path != commonPath {
filename := strings.TrimPrefix(path, commonPath)
filename = strings.TrimPrefix(filename, "/")
filename = strings.TrimPrefix(filename, string(filepath.Separator))
err = ar.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
@ -188,7 +186,7 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
}
defer ar.Close()
commonDir := fileutils.CommonPrefix('/', filenames...)
commonDir := fileutils.CommonPrefix(filepath.Separator, filenames...)
for _, fname := range filenames {
err = addFile(ar, d, fname, commonDir)