Fix underlay provenance and resource path handling
This commit is contained in:
@@ -36,7 +36,7 @@ type rootedNativeFS struct {
|
||||
}
|
||||
|
||||
func (r rootedNativeFS) name(name string) (string, error) {
|
||||
if !fs.ValidPath(name) || strings.Contains(name, "\\") {
|
||||
if !fs.ValidPath(name) {
|
||||
return "", &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid}
|
||||
}
|
||||
joined := path.Join(r.root, name)
|
||||
@@ -75,7 +75,8 @@ type rootedHostFS struct {
|
||||
}
|
||||
|
||||
func (r rootedHostFS) Open(name string) (fs.File, error) {
|
||||
if !fs.ValidPath(name) || strings.Contains(name, "\\") {
|
||||
localName, err := filepath.Localize(name)
|
||||
if err != nil {
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid}
|
||||
}
|
||||
opener := r.openRoot
|
||||
@@ -86,7 +87,7 @@ func (r rootedHostFS) Open(name string) (fs.File, error) {
|
||||
if err != nil {
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: err}
|
||||
}
|
||||
canonical, err := canonicalExistingPath(filepath.Join(r.root, filepath.FromSlash(name)))
|
||||
canonical, err := canonicalExistingPath(filepath.Join(r.root, localName))
|
||||
if err != nil {
|
||||
_ = root.Close()
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: err}
|
||||
|
||||
Reference in New Issue
Block a user