Repository navigation
fix(transport): handle pathless IO objects in multipart encoding and normalize FilePart filename - #101
Open
Adityakk9031 wants to merge 1 commit into
Open
fix(transport): handle pathless IO objects in multipart encoding and normalize FilePart filename#101Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
…normalize FilePart filename
Author
|
Hi @contextualbeer, whenever you have a chance, could you please take a look at this PR? Thank you! |
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.
This PR addresses two related issues when handling
IOobjects during multipart form-data requests:Pathless IO objects in
write_multipart_chunk:write_multipart_chunkmatchedin Pathname | IOand called::File.basename(val.to_path).IOobjects not backed by filesystem paths (such asIO.pipe, sockets, or in-memory streams),val.to_pathisnil. Calling::File.basename(nil)raised aTypeError: no implicit conversion of nil into String, crashing the request.in IO unless val.to_path.nil?before extracting a filename.FilePartfilename basename and missingpathnamerequire:FilePart#initialize, passing anIO(e.g.File.open(...)) storedcontent.to_pathdirectly, retaining full directory paths (unlikePathnameand explicit filenames which usebasename). It now normalizes viacontent.to_path&.then { ::File.basename(_1) }.require "pathname"tofile_part.rbto preventNameError: uninitialized constant ContextDev::FilePart::PathnamewhenFilePartis loaded standalone.Added tests for pathless IO multipart encoding and
FilePartfilename extraction.cc @contextualbeer