Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Apr 24, 2024
1 parent d88273a commit 4e90cd4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions context/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
)

// ResolveFS accepts a single input argument of any type
Expand Down Expand Up @@ -134,15 +135,11 @@ var ResolveHTTPFS = func(fsOrDir interface{}) http.FileSystem {
// FindNames accepts a "http.FileSystem" and a root name and returns
// the list containing its file names.
func FindNames(fileSystem http.FileSystem, name string) ([]string, error) {
_, filename, ok, err := SafeFilename("", name)
if err != nil {
return nil, err
}
if !ok {
return nil, fmt.Errorf("invalid file name: %s", name)
if strings.Contains(name, "..") {
return nil, fmt.Errorf("invalid root name")
}

f, err := fileSystem.Open(filename)
f, err := fileSystem.Open(name) // it's the root dir.
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4e90cd4

Please sign in to comment.