Repository navigation
Require pathname in FormData::File - #40
Merged
Merged
Conversation
FormData::File checks for and opens Pathnames, but never required pathname. RubyGems usually loads it first, so it only showed up with --disable-gems, where File.new raised NameError on Ruby 3.4 and older. Ruby 4.0 has Pathname in core.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FormData::Filechecks for Pathnames and opens them, but nothing ever requiredpathname. Normally RubyGems has already loaded it, so nobody noticed. Without RubyGems, as withruby --disable-gems,HTTP::FormData::File.new(StringIO.new("x"))raisesNameError: uninitialized constant HTTP::FormData::File::Pathname. I could reproduce it on 3.2 and 3.4. Ruby 4.0 has Pathname in core, so it's fine there.The fix is a one-line
require "pathname". The test runs Ruby without RubyGems in a child process, because in the test process Pathname is always loaded already. It also clearsRUBYOPT, since underbundle execthat carries-rbundler/setup, which loads Pathname and hid the bug. Without the fix, the test fails.