Fix parsing xml input by ActionDispatch::ParamsParser
[#4437 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
parent
902861a43a
commit
1e1d30715e
@ -38,7 +38,7 @@ def parse_formatted_parameters(env)
|
||||
when Proc
|
||||
strategy.call(request.raw_post)
|
||||
when :xml_simple, :xml_node
|
||||
data = Hash.from_xml(request.body) || {}
|
||||
data = Hash.from_xml(request.body.read) || {}
|
||||
request.body.rewind if request.body.respond_to?(:rewind)
|
||||
data.with_indifferent_access
|
||||
when :yaml
|
||||
|
@ -16,6 +16,19 @@ def teardown
|
||||
TestController.last_request_parameters = nil
|
||||
end
|
||||
|
||||
test "parses a strict rack.input" do
|
||||
class Linted
|
||||
def call(env)
|
||||
bar = env['action_dispatch.request.request_parameters']['foo']
|
||||
result = "<ok>#{bar}</ok>"
|
||||
[200, {"Content-Type" => "application/xml", "Content-Length" => result.length.to_s}, result]
|
||||
end
|
||||
end
|
||||
req = Rack::MockRequest.new(ActionDispatch::ParamsParser.new(Linted.new))
|
||||
resp = req.post('/', "CONTENT_TYPE" => "application/xml", :input => "<foo>bar</foo>", :lint => true)
|
||||
assert_equal "<ok>bar</ok>", resp.body
|
||||
end
|
||||
|
||||
test "parses hash params" do
|
||||
with_test_routing do
|
||||
xml = "<person><name>David</name></person>"
|
||||
|
Loading…
Reference in New Issue
Block a user