Fix underlay provenance and resource path handling

This commit is contained in:
2026-09-29 20:03:39 +00:00
parent 15f5083282
commit b604aa167b
6 changed files with 217 additions and 8 deletions

View File

@@ -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}