mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
minor
This commit is contained in:
parent
d88273ab55
commit
4e90cd4e4d
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResolveFS accepts a single input argument of any type
|
// ResolveFS accepts a single input argument of any type
|
||||||
|
@ -134,15 +135,11 @@ var ResolveHTTPFS = func(fsOrDir interface{}) http.FileSystem {
|
||||||
// FindNames accepts a "http.FileSystem" and a root name and returns
|
// FindNames accepts a "http.FileSystem" and a root name and returns
|
||||||
// the list containing its file names.
|
// the list containing its file names.
|
||||||
func FindNames(fileSystem http.FileSystem, name string) ([]string, error) {
|
func FindNames(fileSystem http.FileSystem, name string) ([]string, error) {
|
||||||
_, filename, ok, err := SafeFilename("", name)
|
if strings.Contains(name, "..") {
|
||||||
if err != nil {
|
return nil, fmt.Errorf("invalid root name")
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("invalid file name: %s", name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := fileSystem.Open(filename)
|
f, err := fileSystem.Open(name) // it's the root dir.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user