rack-indifferent¶ ↑
rack-indifferent modifies rack to make the hash it stores query params in support indifferent access (access via strings or symbols). This makes it so web frameworks/applications that use rack-indifferent don’t have to make a deep copy of the params to allow indifferent access to the params.
Note that while this allows you to save a character when accessing the params (params[:param_name]
instead of params["param_name"]
), it is a bad idea in general as it makes it more difficult to separate untrusted external data access (via strings) from internal trusted data (via symbols). Mixing the two types of data access (i.e. treating untrusted data as trusted) is a common security vulnerability, and this library makes it easier to be vulnerable.
Installation¶ ↑
gem install rack-indifferent
Source Code¶ ↑
Source code is available on GitHub at github.com/jeremyevans/rack-indifferent
Basic Usage¶ ↑
You just need to require the library:
require 'rack/indifferent'
On rack 1, this will monkey patch a rack class to change the query params hashes that rack uses to use indifferent access.
On rack 2, this will set a new default query parser that uses hashes with indifferent access. Note that web frameworks and applications that use custom query parsers in their request class will not be affected by rack-indifferent.
License¶ ↑
MIT
Maintainer¶ ↑
Jeremy Evans <code@jeremyevans.net>