ValidatePath refused a .. segment but accepted a . segment, so a manifest could list ./a.txt. check then verified a.txt and also reported it as an extra file, and one file could be listed twice under two spellings despite the listed-once rule. A . segment is now refused when a manifest is written and when it is loaded, and the Path Rules in docs/FORMAT.md and the path comment in mfer/mf.proto list it. Two fetch tests listed ./ paths to check name clashes; such manifests can no longer be built, so those cases are removed. Model: opus-5-5
This commit is contained in:
@@ -34,6 +34,7 @@ var (
|
||||
errPathAbsolute = errors.New("is absolute; must be relative")
|
||||
errPathEmptySegment = errors.New("contains empty segment")
|
||||
errPathDotDot = errors.New("contains '..' segment")
|
||||
errPathDot = errors.New("contains '.' segment")
|
||||
errSizeMismatch = errors.New("size mismatch")
|
||||
errNegativeSize = errors.New("size cannot be negative")
|
||||
errHashNotMultihash = errors.New("hash is not a valid multihash")
|
||||
@@ -46,6 +47,7 @@ var (
|
||||
// - Must use forward slashes only (no backslashes)
|
||||
// - Must be relative (no leading /)
|
||||
// - Must not contain ".." segments
|
||||
// - Must not contain "." segments
|
||||
// - Must not contain empty segments (no "//")
|
||||
// - Must not be empty
|
||||
func ValidatePath(p string) error {
|
||||
@@ -73,6 +75,10 @@ func ValidatePath(p string) error {
|
||||
if seg == ".." {
|
||||
return fmt.Errorf("path %q %w", p, errPathDotDot)
|
||||
}
|
||||
|
||||
if seg == "." {
|
||||
return fmt.Errorf("path %q %w", p, errPathDot)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user