aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2011-03-06 07:08:50 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2011-03-06 07:08:50 +0000
commite00867bc437b6a681491ef59e13423051e6d98f0 (patch)
tree75e82e12162d49368d007f723a1a39dcfe5fe5c3 /actionpack/lib/action_dispatch/routing
parent0509bf35f1987c1e0b9c3dd1389778f8426180f7 (diff)
downloadrails-e00867bc437b6a681491ef59e13423051e6d98f0.tar.gz
rails-e00867bc437b6a681491ef59e13423051e6d98f0.tar.bz2
rails-e00867bc437b6a681491ef59e13423051e6d98f0.zip
Raise ArgumentError if route name is invalid [#6517 state:resolved]
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index fc86d52a3a..61053d4464 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -1,5 +1,6 @@
require 'rack/mount'
require 'forwardable'
+require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/hash/slice'
@@ -330,6 +331,7 @@ module ActionDispatch
end
def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
+ raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
route = Route.new(self, app, conditions, requirements, defaults, name, anchor)
@set.add_route(*route)
named_routes[name] = route if name