From 2bbcff8cf4488c0f64bf5ac23e9b5a8eb13f07d5 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sat, 17 Jun 2006 00:25:24 +0000 Subject: Fix that routes with *path segments in the recall can generate URLs. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4454 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/routing.rb | 2 +- actionpack/test/controller/routing_test.rb | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 34e2ff6a88..6ff02ea01c 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix that routes with *path segments in the recall can generate URLs. [Rick] + * Fix strip_links so that it doesn't hang on multiline tags [Jamis Buck] * Remove problematic control chars in rescue template. #5316 [Stefan Kaes] diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 8638a1afb2..d53becd2a9 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -581,7 +581,7 @@ module ActionController class PathSegment < DynamicSegment EscapedSlash = CGI.escape("/") def interpolation_chunk - "\#{CGI.escape(#{local_name}).gsub(#{EscapedSlash.inspect}, '/')}" + "\#{CGI.escape(#{local_name}.to_s).gsub(#{EscapedSlash.inspect}, '/')}" end def default diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index b2c3ebf410..e6d42c823f 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -214,6 +214,15 @@ class LegacyRouteSetTests < Test::Unit::TestCase assert_equal '/pages/boo', rs.generate(:controller => 'content', :action => 'show_file', :path => %w(pages boo)) end + def test_dynamic_recall_paths_allowed + rs.draw do |map| + map.connect '*path', :controller => 'content', :action => 'show_file' + end + + recall_path = ActionController::Routing::PathSegment::Result.new(%w(pages boo)) + assert_equal '/pages/boo', rs.generate({}, :controller => 'content', :action => 'show_file', :path => recall_path) + end + def test_backwards rs.draw do |map| map.connect 'page/:id/:action', :controller => 'pages', :action => 'show' -- cgit v1.2.3