-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow access to '..' in mapfs #7575
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -478,3 +478,21 @@ func TestFS_RemoveAll(t *testing.T) { | |
require.ErrorIs(t, err, fs.ErrNotExist) | ||
}) | ||
} | ||
|
||
func TestFS_WithUnderlyingRoot(t *testing.T) { | ||
root := "testdata/subdir" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, thanks. |
||
fsys := mapfs.New(mapfs.WithUnderlyingRoot(root)) | ||
fsys.WriteFile("foo.txt", root+"/foo.txt") | ||
|
||
fi, err := fsys.Stat("..") | ||
require.NoError(t, err) | ||
assert.True(t, fi.IsDir()) | ||
|
||
fi, err = fsys.Stat("../hello.txt") | ||
require.NoError(t, err) | ||
assert.False(t, fi.IsDir()) | ||
|
||
fi, err = fsys.Stat("foo.txt") | ||
require.NoError(t, err) | ||
assert.False(t, fi.IsDir()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A regular file can have
..
prefix.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a002320