From 0b0a704d44f4890071332634d3cdd3af4725481f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 18 Jul 2020 19:10:22 +0100 Subject: [PATCH] chore: remove hacdias/fileutils dep (#1037) --- go.mod | 1 - go.sum | 2 -- http/raw.go | 11 +++++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 7e2e3bed..4664fe03 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/golang/snappy v0.0.1 // indirect github.com/gorilla/mux v1.7.3 github.com/gorilla/websocket v1.4.1 - github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1 github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1 github.com/mholt/archiver v3.1.1+incompatible github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index f29e3441..a9813849 100644 --- a/go.sum +++ b/go.sum @@ -87,8 +87,6 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1 h1:2MkEawJQTmAr6YI7T7j7SKxdTmYJOcaJZfzeVPr56PM= -github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1/go.mod h1:lwnswzFVSy7B/k81M5rOLUU0fOBKHrDRIkPIBZd7PBo= github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= diff --git a/http/raw.go b/http/raw.go index c3796bef..4976252b 100644 --- a/http/raw.go +++ b/http/raw.go @@ -4,16 +4,23 @@ import ( "errors" "net/http" "net/url" + gopath "path" "path/filepath" "strings" - "github.com/hacdias/fileutils" "github.com/mholt/archiver" "github.com/filebrowser/filebrowser/v2/files" "github.com/filebrowser/filebrowser/v2/users" ) +func slashClean(name string) string { + if name == "" || name[0] != '/' { + name = "/" + name + } + return gopath.Clean(name) +} + func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]string, error) { var fileSlice []string names := strings.Split(r.URL.Query().Get("files"), ",") @@ -27,7 +34,7 @@ func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]strin return nil, err } - name = fileutils.SlashClean(name) + name = slashClean(name) fileSlice = append(fileSlice, filepath.Join(f.Path, name)) } }