Skip to content

Commit 25c8491

Browse files
committed
feat(serverHandler/mutate): use platform-specific normalized path
1 parent 5b096f2 commit 25c8491

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/serverHandler/delete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"net/http"
66
"os"
7+
"path/filepath"
78
)
89

910
func (h *handler) deleteItems(authUserName, fsPrefix string, files []string, aliasSubItems []os.FileInfo, r *http.Request) bool {
@@ -23,7 +24,7 @@ func (h *handler) deleteItems(authUserName, fsPrefix string, files []string, ali
2324
if containsItem(aliasSubItems, filename) {
2425
continue
2526
}
26-
fsPath := fsPrefix + "/" + filename
27+
fsPath := filepath.Join(fsPrefix, filename)
2728
h.logMutate(authUserName, "delete", fsPath, r)
2829
err := os.RemoveAll(fsPath)
2930
if err != nil {

src/serverHandler/mkdir.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"net/http"
66
"os"
7+
"path/filepath"
78
"strings"
89
)
910

@@ -30,7 +31,7 @@ func (h *handler) mkdirs(authUserName, fsPrefix string, files []string, aliasSub
3031
errs = append(errs, errors.New("mkdir: ignore path shadowed by alias "+filename))
3132
continue
3233
}
33-
fsPath := fsPrefix + "/" + filename
34+
fsPath := filepath.Join(fsPrefix, filename)
3435
h.logMutate(authUserName, "mkdir", fsPath, r)
3536
err := os.MkdirAll(fsPath, 0755)
3637
if err != nil {

src/serverHandler/upload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"mime/multipart"
99
"net/http"
1010
"os"
11-
"path"
11+
"path/filepath"
1212
"strconv"
1313
"strings"
1414
)
@@ -163,7 +163,7 @@ func (h *handler) saveUploadFiles(authUserName, fsPrefix string, createDir, over
163163
continue
164164
}
165165

166-
fsPath := path.Clean(filePrefix + "/" + fsFilename)
166+
fsPath := filepath.Join(filePrefix, fsFilename)
167167
h.logUpload(authUserName, filename, fsPath, r)
168168
file, err := os.OpenFile(fsPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
169169
if err != nil {

0 commit comments

Comments
 (0)