Avoid mutating caller components in FTP.build - #251
Open
OskarEichler wants to merge 2 commits into
Open
Conversation
olleolleolle
approved these changes
Aug 28, 2026
olleolleolle
left a comment
Contributor
There was a problem hiding this comment.
The change looks reasonable, and allows the caller to own what they passed in to the method.
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.
Summary
Normalize the FTP path after make_components_hash has copied the input. Do not replace entries in the caller Hash or Array before copying.
Reproduction
Build twice from
{host: 'example.test', path: '/folder'}. Before, the first build changes the caller path to '/%2Ffolder' and the next build encodes it again. Frozen Hash/Array inputs raise FrozenError. After, repeated builds are equivalent and input components remain unchanged.Verification
bundle exec rake test: 93 tests / 3,039 assertions / zero failures or errors, both baseline and this isolated patch.git diff --checkpass. Supplemental Lint adds no findings against the 31-finding baseline.Compatibility and limitations
Intentional ownership correction: FTP.build no longer mutates caller components. Generated URIs for the initial input remain the same. No public API removal, dependency change or Ruby minimum change.
Based on master
696df43b0be4c05d3a0dcf7db582126c915d860d. Other Ruby/OS runtimes were not executed locally. No production traffic or live mail/FTP services were used. Existing related PRs/issues were checked; this is a focused contribution, not exhaustive behavioral coverage.