aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/routing.rb1
-rw-r--r--actionpack/test/controller/routing_tests.rb11
3 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 3d8d6f1ceb..dbfb4b6b30 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that Routes would raise NameErrors if a controller component contains characters that are not valid constant names #733 [Nicholas Seckar]
+
* Added PATH_INFO access from the request that allows urls like the following to be interpreted by rails: http://www.example.com/dispatcher.cgi/controller/action -- that makes it possible to use rails as a CGI under lighttpd and would also allow (for example) Rublog to be ported to rails without breaking existing links to Rublog-powered blogs. #728 [Jamis Buck]
* Fixed that caching the root would result in .html not index.html #731 [alisdair]
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index d270defa4d..ab568b6595 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -134,6 +134,7 @@ module ActionController
def eat_path_to_controller(path)
path.inject([Controllers, 1]) do |(mod, length), name|
name = name.camelize
+ return nil, nil unless /^[A-Z][_a-zA-Z\d]*$/ =~ name
controller_name = name + "Controller"
return mod.const_get(controller_name), path[length..-1] if mod.const_available? controller_name
return nil, nil unless mod.const_available? name
diff --git a/actionpack/test/controller/routing_tests.rb b/actionpack/test/controller/routing_tests.rb
index f1a3254a42..360ca06cf8 100644
--- a/actionpack/test/controller/routing_tests.rb
+++ b/actionpack/test/controller/routing_tests.rb
@@ -479,6 +479,17 @@ class RouteSetTests < Test::Unit::TestCase
@request.path_parameters = {:controller => 'admin/users', :action => 'index'}
verify_generate 'admin/users', {}
end
+
+ def test_url_with_spaces_in_controller
+ @request.path = 'not%20a%20valid/controller/name'
+ @set.add_route(@rails_route) if @set.empty?
+ assert_raises(ActionController::RoutingError) {@set.recognize!(@request)}
+ end
+ def test_url_with_dots_in_controller
+ @request.path = 'not.valid/controller/name'
+ @set.add_route(@rails_route) if @set.empty?
+ assert_raises(ActionController::RoutingError) {@set.recognize!(@request)}
+ end
end
#require '../assertions/action_pack_assertions.rb'