Skip to content
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

os.pwd / "../folder/../Out.txt" seems to be allowed despite being a non-canonical sub-path #327

Open
lihaoyi opened this issue Oct 29, 2024 · 2 comments

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Oct 29, 2024

Seems like we should error and ask people to us "../Out.txt"? @pawelsadlo what do you think?

@pawelsadlo
Copy link
Contributor

pawelsadlo commented Oct 29, 2024

@lihaoyi
I am not sure how would it behave in case folder is symlink.
We should check what is behavior in case of symlink without literal. - os.pwd / ".." / folder / "Out.txt"

@lihaoyi
Copy link
Member Author

lihaoyi commented Oct 30, 2024

Mill already normalizes os.pwd / ".." / "folder" / ".." / "Out.txt" to os.pwd / ".." / "Out.txt" on-creation, even before we perform any filesystem operations, so whether symlinks behave correctly or not, those are the semantics we already use

lihaoyi added a commit that referenced this issue Nov 12, 2024
Addresses #327 

This PR adds additional validation of literal path segments containing
`..`.

It throws compiletime error, suggesting canonical form of a path, when
literal path is not canonical.

Eg. "../foo/../bar"   suggests  "../bar"

"foo/.." suggests removing literal

---------

Co-authored-by: Li Haoyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants