You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is enough to change the class of request.filtered_parameters from ActiveSupport::HashWithIndifferentAccess to Hash. Omitting this line (defaults to []) returns a duplicate of parameters which is a ActiveSupport::HashWithIndifferentAccess.
Expected behavior
ParameterFilter should return the a hash with the same class than the parameters it is filtering.
Actual behavior
When filtering, ParameterFilter creates a new copy of the hash but looses its indifferent access property.
System configuration
Rails version: 5.0.1
Ruby version: 2.3.1
Failing Test
beginrequire'bundler/inline'rescueLoadError=>e
$stderr.puts'Bundler version 1.10 or later is required. Please update your Bundler'raiseeendgemfile(true)dosource'https://rubygems.org'gem'rails',github: 'rails/rails',branch: '5-0-stable'gem'arel',github: 'rails/arel',branch: '7-1-stable'gem'byebug'endrequire'action_controller/railtie'classTestApp < Rails::Applicationconfig.root=File.dirname(__FILE__)config.session_store:cookie_store,key: 'cookie_store_key'secrets.secret_token='secret_token'secrets.secret_key_base='secret_key_base'config.logger=Logger.new($stdout)Rails.logger=config.loggerroutes.drawdoget'/'=>'test#index'endendclassTestController < ActionController::BaseincludeRails.application.routes.url_helpersdefindexrenderplain: 'Home'endendrequire'minitest/autorun'require'rack/test'classBugTest < Minitest::TestincludeRack::Test::Methodsdeftest_returns_successget'/'assertlast_response.ok?enddeftest_parameter_filter_class[[{'foo'=>'bar'}.with_indifferent_access,%w'bar'],[{'bar'=>'foo'}.with_indifferent_access,[]]].eachdo |before_filter,filter_words|
parameter_filter=ActionDispatch::Http::ParameterFilter.new(filter_words)assert_instance_ofActiveSupport::HashWithIndifferentAccess,parameter_filter.filter(before_filter)endendprivatedefappRails.applicationendend
1) Failure:
BugTest#test_parameter_filter_class [failing_test.rb:56]:
Expected {"foo"=>"bar"} to be an instance of ActiveSupport::HashWithIndifferentAccess, not Hash.
The text was updated successfully, but these errors were encountered:
… class to be Hash
- Fixes issue described on rails#27944
- `filtered_query_string` used an Array representation of what
semantically is a key value pair: better suited for a Hash. Without
this change `filtered_params = original_params.class.new` returns an
Array with unintended consequences.
Steps to reproduce
By default all Rails apps are created with an initializer called filter_parameter_logging.rb and its default contents are:
This is enough to change the class of
request.filtered_parameters
fromActiveSupport::HashWithIndifferentAccess
toHash
. Omitting this line (defaults to[]
) returns a duplicate of parameters which is aActiveSupport::HashWithIndifferentAccess
.Expected behavior
ParameterFilter
should return the a hash with the same class than the parameters it is filtering.Actual behavior
When filtering,
ParameterFilter
creates a new copy of the hash but looses its indifferent access property.System configuration
Rails version: 5.0.1
Ruby version: 2.3.1
Failing Test
The text was updated successfully, but these errors were encountered: