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
Discrepancy in the parsing behavior of Rack::Multipart between versions 1.6 and 2.2 #2171
Comments
There is no such version of |
Is there a way to make it backwards compatible?
Updated. @ioquatix it is 2.2.8.1 |
I don't think either Rack 1.x or 2.x will be modified. What are you proposing needs to be done? |
@ioquatix Is there a way to get the earlier behaviour working in Rack version 2.2? |
I don't think so unless you were willing to copy and monkey patch the code. |
What does the input stream look like? Does it meet the HTTP specification? Is one version of Rack departing from specified behaviour, or are they both just making different guesses about a malformed input? Have you identified what change in Rack caused the difference? |
@matthewd It does look like below:
|
It seems like there's a discrepancy in the parsing behavior of Rack::Multipart between versions 1.6 and 2.8. The key difference lies in how the multipart form data is parsed and structured in the resulting hash.
[198] pry(main)> env = Rack::MockRequest.env_for '/', fixture
=> {"rack.version"=>[1, 3],
"rack.input"=>#StringIO:0x00007fc8e0cdb508,
"rack.errors"=>#StringIO:0x00007fc8d5075f30,
"rack.multithread"=>true,
"rack.multiprocess"=>true,
"rack.run_once"=>false,
"REQUEST_METHOD"=>"GET",
"SERVER_NAME"=>"example.org",
"SERVER_PORT"=>"80",
"QUERY_STRING"=>"",
"PATH_INFO"=>"/",
"rack.url_scheme"=>"http",
"HTTPS"=>"off",
"SCRIPT_NAME"=>"",
"CONTENT_LENGTH"=>"1048802",
"CONTENT_TYPE"=>"multipart/form-data; boundary=---------------------------932620571087722842402766118"}
[199] pry(main)> Rack::Multipart.parse_multipart(env)
VERSION rack 2.2.8.1
=> {"a.pdf"=>
{:filename=>"a.pdf",
:type=>nil,
:name=>"a.pdf",
:tempfile=>#File:/var/folders/dq/gh_0mwnd2mg9zjksn9l5h5580000gp/T/RackMultipart20240422-84772-4g22na.pdf,
:head=>"Content-Disposition: form-data; filename="a.pdf"; size=12545 name="a[p]"\r\nContent-Type:application/pdf\r\n"}}
**VERSION rack 1.6 **
=> {"a"=>
{"p"=>
{:filename=>"a.pdf",
:type=>nil,
:name=>"a[p]",
:tempfile=>#File:/var/folders/dq/gh_0mwnd2mg9zjksn9l5h5580000gp/T/RackMultipart20240422-63994-9ofkkg.pdf,
:head=>"Content-Disposition: form-data; filename="a.pdf"; size=12545 name="a[p]"\r\n" + "Content-Type:application/pdf\r\n"}}}
The text was updated successfully, but these errors were encountered: