From f9f84d9f6dea72cae4fc8e31448df408caccbd59 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 28 Dec 2006 21:04:44 +0000 Subject: Routing uses URI escaping for path components and CGI escaping for query parameters. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5803 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/routing_test.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 43397dee35..ced8ca2dc6 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -207,8 +207,15 @@ class LegacyRouteSetTests < Test::Unit::TestCase map.path 'file/*path', :controller => 'content', :action => 'show_file' map.connect ':controller/:action/:id' end + + # No + to space in URI escaping, only for query params. results = rs.recognize_path "/file/hello+world/how+are+you%3F" assert results, "Recognition should have succeeded" + assert_equal ['hello+world', 'how+are+you?'], results[:path] + + # Use %20 for space instead. + results = rs.recognize_path "/file/hello%20world/how%20are%20you%3F" + assert results, "Recognition should have succeeded" assert_equal ['hello world', 'how are you?'], results[:path] results = rs.recognize_path "/file" @@ -1457,11 +1464,11 @@ class RouteSetTest < Test::Unit::TestCase def test_recognize_with_encoded_id_and_regex set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /[a-zA-Z0-9 ]+/ + map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /[a-zA-Z0-9\+]+/ end assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) - assert_equal({:controller => 'pages', :action => 'show', :id => 'hello world'}, set.recognize_path('/page/hello+world')) + assert_equal({:controller => 'pages', :action => 'show', :id => 'hello+world'}, set.recognize_path('/page/hello+world')) end def test_recognize_with_conditions -- cgit v1.2.3