rails/rails — pull request #9024 by ethansr (2013-01-22 03:51:41+00:00)
Title: ParamsParser calls rewind on rack.input if needed

There was a lot of churn in the ParamsParser while fixing CVE-2013-0156
This attempts to restore intended functionality as faithfully as can be
from 3957d44 for JSON and e1a0d86 for XML.

Also added is a integration test RackInputRewindTest which checks to
make sure that ParamsParser rewinds rack.input for both cases.

In some cases request.body can be [rack.input](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb#L226), so if ParamsParser doesn't rewind it unexpected things can happen. See rails#8490

I encountered this trying to get the better_errors gem working in Rails 4.
I've created a test app here: https://github.com/ethansr/rack_input to show [better_errors](https://github.com/charliesome/better_errors/blob/master/lib/better_errors/middleware.rb#L113) failing because it expects the env['rack.input'] StringIO to be at its start.

If the app is working correctly a stack trace will appear on the right side. If it isn't then a strack trace similar to this: https://gist.github.com/4591803 will appear in the logs.

I realize this is sensitive file to touch right now and would appreciate any feedback.