Skip to content

Commit 0b0a704

Browse files
authored
chore: remove hacdias/fileutils dep (filebrowser#1037)
1 parent 2d99d0b commit 0b0a704

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/golang/snappy v0.0.1 // indirect
1414
github.com/gorilla/mux v1.7.3
1515
github.com/gorilla/websocket v1.4.1
16-
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1
1716
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1
1817
github.com/mholt/archiver v3.1.1+incompatible
1918
github.com/mitchellh/go-homedir v1.1.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
8787
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
8888
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
8989
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
90-
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1 h1:2MkEawJQTmAr6YI7T7j7SKxdTmYJOcaJZfzeVPr56PM=
91-
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1/go.mod h1:lwnswzFVSy7B/k81M5rOLUU0fOBKHrDRIkPIBZd7PBo=
9290
github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=
9391
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
9492
github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=

http/raw.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ import (
44
"errors"
55
"net/http"
66
"net/url"
7+
gopath "path"
78
"path/filepath"
89
"strings"
910

10-
"github.com/hacdias/fileutils"
1111
"github.com/mholt/archiver"
1212

1313
"github.com/filebrowser/filebrowser/v2/files"
1414
"github.com/filebrowser/filebrowser/v2/users"
1515
)
1616

17+
func slashClean(name string) string {
18+
if name == "" || name[0] != '/' {
19+
name = "/" + name
20+
}
21+
return gopath.Clean(name)
22+
}
23+
1724
func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]string, error) {
1825
var fileSlice []string
1926
names := strings.Split(r.URL.Query().Get("files"), ",")
@@ -27,7 +34,7 @@ func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]strin
2734
return nil, err
2835
}
2936

30-
name = fileutils.SlashClean(name)
37+
name = slashClean(name)
3138
fileSlice = append(fileSlice, filepath.Join(f.Path, name))
3239
}
3340
}

0 commit comments

Comments
 (0)