-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improve handling of paths with invalid Windows characters #9276
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
base: master
Are you sure you want to change the base?
Conversation
Add validation and clear error messages for gems with filenames containing invalid Windows characters (e.g., colons), directing users to report issues to gem authors instead of RubyGems.
bbb7488 to
c9af675
Compare
d8abe69 to
a8dfff3
Compare
| out.flush | ||
| out.chmod file_mode(entry.header.mode) & ~File.umask | ||
| end | ||
| rescue Errno::EINVAL |
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.
Thank you for providing this PR!
Is the rescue really necessary? The filenames are checked for invalid characters in advance, so why infer that EINVAL is due to an invalid character? This doesn't make sense on non-Windows OS either.
| def add_files(tar) # :nodoc: | ||
| @spec.files.each do |file| | ||
| if invalid_windows_filename?(file) | ||
| alert_warning "filename '#{file}' contains characters that are invalid on Windows (e.g., colons). This gem may fail to install on Windows." |
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.
The filenames are checked when packaging a gem, which is a very good thing. Could you add a test for it as well?
What is your fix for the problem, implemented in this PR?
Fixes #7681
Windows doesn't allow certain characters in filenames (e.g., colons) that are valid on Unix. When gems contain files with these characters, installation fails on Windows with cryptic
Errno::EINVALerrors.This PR adds validation and directs users to report issues to gem authors instead.
InvalidFileNameErrorwith user-friendly messagesMake sure the following tasks are checked