Skip to content

Conversation

@fogfish
Copy link
Owner

@fogfish fogfish commented Nov 1, 2025

Key Changes:
Updated shared validation functions (filename.go):

IsValidFile(), IsValidPath(), and IsValidDir() now accept paths with or without leading / Both /file.txt and file.txt are treated as equivalent paths relative to the mount point Relative paths with .. are still rejected by fs.ValidPath() Both filesystems now behave identically:

S3 filesystem (stream): Already had path normalization in s3Key() that strips leading / Local filesystem (lfs): Uses trim() function to normalize paths before filesystem operations Both accept the same path formats and treat them consistently Updated documentation:

Both Create() and Open() methods in both filesystems now document that paths can be with or without leading / Clear that both forms are treated as paths relative to the mount point Behavior:
Before:

Paths required leading / → fsys.Create("/file.txt", nil) ✅ Paths without / failed → fsys.Create("file.txt", nil) ❌ After:

Both forms work equally → fsys.Create("/file.txt", nil) ✅ → fsys.Create("file.txt", nil) ✅
Both are treated as the same file at the mount root No support for relative traversal with ../ (correctly rejected)

Key Changes:
Updated shared validation functions (filename.go):

IsValidFile(), IsValidPath(), and IsValidDir() now accept paths with or without leading /
Both /file.txt and file.txt are treated as equivalent paths relative to the mount point
Relative paths with .. are still rejected by fs.ValidPath()
Both filesystems now behave identically:

S3 filesystem (stream): Already had path normalization in s3Key() that strips leading /
Local filesystem (lfs): Uses trim() function to normalize paths before filesystem operations
Both accept the same path formats and treat them consistently
Updated documentation:

Both Create() and Open() methods in both filesystems now document that paths can be with or without leading /
Clear that both forms are treated as paths relative to the mount point
Behavior:
Before:

Paths required leading / → fsys.Create("/file.txt", nil) ✅
Paths without / failed → fsys.Create("file.txt", nil) ❌
After:

Both forms work equally → fsys.Create("/file.txt", nil) ✅
→ fsys.Create("file.txt", nil) ✅
Both are treated as the same file at the mount root
No support for relative traversal with ../ (correctly rejected)
@fogfish fogfish merged commit f02b866 into main Nov 1, 2025
4 checks passed
@fogfish
Copy link
Owner Author

fogfish commented Nov 1, 2025

closes #53
closes #31

This was referenced Nov 1, 2025
@fogfish fogfish deleted the fix-path-inconsistency branch November 1, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants