diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-21 10:05:07 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-21 10:05:07 +0000 |
commit | de0a0d700e8c3959a3503152b9a495616afbeae5 (patch) | |
tree | 0044f82e2220295c1244996d333afb822730c854 /actionpack/test | |
parent | f29857690fee7fa8350f79922e349669480c0329 (diff) | |
download | rails-de0a0d700e8c3959a3503152b9a495616afbeae5.tar.gz rails-de0a0d700e8c3959a3503152b9a495616afbeae5.tar.bz2 rails-de0a0d700e8c3959a3503152b9a495616afbeae5.zip |
Routing: better support for escaped values in route segments. Closes #7544.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6185 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f81d0393f0..5f75bf3876 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -13,6 +13,46 @@ class ROUTING::RouteBuilder end end +class UriReservedCharactersRoutingTest < Test::Unit::TestCase + # See RFC 3986, section 2.2 Reserved Characters + + def setup + ActionController::Routing.use_controllers! ['controller'] + @set = ActionController::Routing::RouteSet.new + @set.draw do |map| + map.connect ':controller/:action/:var' + end + end + + def test_should_escape_reserved_uri_characters_within_individual_path_components + assert_equal '/controller/action/p1%3Ap2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1:p2') + assert_equal '/controller/action/p1%2Fp2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1/p2') + assert_equal '/controller/action/p1%3Fp2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1?p2') + assert_equal '/controller/action/p1%23p2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1#p2') + assert_equal '/controller/action/p1%5Bp2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1[p2') + assert_equal '/controller/action/p1%5Dp2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1]p2') + assert_equal '/controller/action/p1%40p2', @set.generate(:controller => 'controller', :action => 'action', :var => 'p1@p2') + end + + def test_should_recognize_escaped_path_component_and_unescape + expected_options = {:var => "p1:p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%3Ap2') + expected_options = {:var => "p1/p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%2Fp2') + expected_options = {:var => "p1?p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%3Fp2') + expected_options = {:var => "p1#p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%23p2') + expected_options = {:var => "p1[p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%5Bp2') + expected_options = {:var => "p1]p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%5Dp2') + expected_options = {:var => "p1@p2", :controller => "controller", :action => "action"} + assert_equal expected_options, @set.recognize_path('/controller/action/p1%40p2') + end + +end + class LegacyRouteSetTests < Test::Unit::TestCase attr_reader :rs def setup |