Repository is archived
No release in over 3 years
Low commit activity in last 3 years
rack-indifferent monkey patches Rack::Utils::KeySpaceConstrainedParams to make the hash it stores params in support indifferent access. So web frameworks that use rack-indifferent don't have to make a deep copy of the params to allow indifferent access to the params.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3

Runtime

>= 1.5
 Project Readme

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>