Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly unescape recognized path components. Fixes #1651.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1764 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5727dc2f42874e32f8cac3c176a085de07b24dd9 1 parent e3af27c
Nicholas Seckar seckar authored
5 actionpack/lib/action_controller/routing.rb
View
@@ -245,12 +245,15 @@ def write_recognition(g)
start = "(#{start})" unless /^\w+$/ =~ start
value_expr = "#{g.path_name}[#{start}..-1] || []"
- g.result key, "ActionController::Routing::PathComponent::Result.new(#{value_expr})"
+ g.result key, "ActionController::Routing::PathComponent::Result.new_escaped(#{value_expr})"
g.finish(false)
end
class Result < ::Array
def to_s() join '/' end
+ def self.new_escaped(strings)
+ new strings.collect {|str| CGI.unescape str}
+ end
end
end
11 actionpack/test/controller/routing_test.rb
View
@@ -693,6 +693,17 @@ def test_changing_controller
)
end
+ def test_paths_escaped
+ rs.draw do |map|
+ rs.path 'file/*path', :controller => 'content', :action => 'show_file'
+ rs.connect ':controller/:action/:id'
+ end
+
+ results = rs.recognize_path %w(file hello+world how+are+you%3F)
+ assert results, "Recognition should have succeeded"
+ assert_equal ['hello world', 'how are you?'], results['path']
+ end
+
def test_backwards
rs.draw do |map|
rs.connect 'page/:id/:action', :controller => 'pages', :action => 'show'
Please sign in to comment.
Something went wrong with that request. Please try again.