-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add checks for Windows reserved filenames in cargo install process #8160
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
Conversation
Following issue rust-lang#8055, added a block before the unpacking stage of `cargo install` to check if any of the paths that the package has contains files or folders with reserved Windows filenames. - Added an error message for these specific cases pointing which is the path an the file that are actually causing the error. - Added an error message for failed obtentions of the path as &str if the Path contains non-UTF8 characters which are non-valid Paths in Windows.
Following rust-lang#8055 we need to propperly print errors if the path to any file of the package contains a windows reserved filename. - Added tests for packages with a file that has a reserved filename on Windows. - Added tests for packages with a folder that has a reserved filaname on Windows.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
// If the path contains non UTF-8 characters, provide the | ||
// propper error. | ||
.ok_or(crate::util::errors::ProcessError { | ||
desc: String::from("Invalid UTF8 character in the file path"), | ||
exit: None, | ||
output: None, | ||
}) | ||
.chain_err(|| "Invalid UTF8 character in the file path")? |
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.
I don't know if that's needed, but It would be weird if the path contains a non-UTF-8 character and the process just panics pointing to the unwrap()
that would replace this code.
If you feel that this should not be checked here, I can just unwrap()
and that's it. (Or if you have better suggestions, happy to hear & apply them!)
Thanks for the PR! However, there seems to be one already open for this at #8136. |
Oh.. didn't see the issue assigned to anyone so I decided to go for it. My bad.. I guess this can be closed unless any of the checks I'm doing is not done on the other PR. Thanks anyway and hope I can contribute on something else soon. |
☔ The latest upstream changes (presumably #8136) made this pull request unmergeable. Please resolve the merge conflicts. |
No worries, sorry for the confusion, thanks for taking a look, though! |
Hey @ehuss I'm a bit confused. You mentioned that #8136 was already doing this, but after reviewing it now and making some tests with this commit merged, I realized it was not (as far as I've seen). #8136 as far as I've seen is actually warning on My PR was indeed taking care of these already-published crates and outputing an error telling the user that indeed they were not possible to install with Idk if you considered that it's not needed, in which case, it's totally fine,. Otherways, we can have explicit errors when using Sorry for the inconvenience if this does not apply 😄 |
The extraction code path is the same for
Notice that it says "aux.rs` appears to contain a reserved Windows path, it cannot be extracted on Windows". Are you not seeing that error? Are you sure you have the latest master? What is the exact commands that you are running and the exact error you are seeing? |
That was my bad. Didn't had a Windows machine now to write the test to check it, and didn't know that the path was the same for both commands. So I raised the flag to early. It should forget about this and look for other begginer issues to work on since all of this seems to be nor correctly handled everywhere. Sorry for the inconvenience. |
Hi, my first PR here, so happy to get any advices if the code can be improved or something doesn't seem correct! 😄
Following issue #8055, added a block before the
unpacking stage of
cargo install
to check if any ofthe paths that the package has, contains files or folders
with reserved Windows filenames.
Added an error message for these specific cases pointing which is
the path an the file that are actually causing the error.
Added an error message for failed obtentions of the path as &str
if the Path contains non-UTF8 characters which are non-valid Paths
in Windows.
Added test for packages with a file/folder that has a reserved filename on
Windows.