Permalink
Browse files

Duplicate possible frozen string from route

Ruby 1.9 freezes Hash string keys by default so where a route is
defined like this:

get 'search' => 'search'

then the Mapper will derive the action from the key. This blows up
later when the action is added to the parameters hash and the
encoding is forced.

Closes #3429
  • Loading branch information...
pixeltrix committed Jan 21, 2013
1 parent a3aca81 commit 431759614d84395faa713ebdfa8bd1cadc97183a
Showing with 10 additions and 2 deletions.
  1. +3 −2 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +7 −0 actionpack/test/dispatch/routing_test.rb
@@ -1288,9 +1288,10 @@ def decomposed_match(path, options) # :nodoc:
def add_route(action, options) # :nodoc:
path = path_for_action(action, options.delete(:path))
+ action = action.to_s.dup
- if action.to_s =~ /^[\w\/]+$/
- options[:action] ||= action unless action.to_s.include?("/")
+ if action =~ /^[\w\/]+$/
+ options[:action] ||= action unless action.include?("/")
else
action = nil
end
@@ -515,6 +515,8 @@ def self.call(params, request)
match '/sculptors', :to => 'italians#sculptors'
match '/painters/:painter', :to => 'italians#painters', :constraints => {:painter => /michelangelo/}
end
+
+ get 'search' => 'search'
end
end
@@ -2477,6 +2479,11 @@ def test_root_in_deeply_nested_scope
assert_equal "/posts/1/admin", post_admin_root_path(:post_id => '1')
end
+ def test_action_from_path_is_not_frozen
+ get '/search'
+ assert !@request.params[:action].frozen?
+ end
+
private
def with_test_routes
yield

0 comments on commit 4317596

Please sign in to comment.