diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-09-18 17:49:46 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2010-09-18 17:49:46 +0100 |
commit | 0bffd7d933a46df958c3e6bae1d9871aca515a12 (patch) | |
tree | 9d82a3b2e71a8275db33ace3585455a9f531362d /actionpack/lib | |
parent | 013ed1c0503e59dc8f1cfff1bd00d0e579c604a1 (diff) | |
download | rails-0bffd7d933a46df958c3e6bae1d9871aca515a12.tar.gz rails-0bffd7d933a46df958c3e6bae1d9871aca515a12.tar.bz2 rails-0bffd7d933a46df958c3e6bae1d9871aca515a12.zip |
Raise ArgumentError instead of normalizing controller name when there is a leading slash [#5651 state:resolved]
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 42ca351cfa..fe85acb94e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -137,7 +137,7 @@ module ActionDispatch { } else if to.is_a?(String) - controller, action = to.sub(%r{\A/}, '').split('#') + controller, action = to.split('#') elsif to.is_a?(Symbol) action = to.to_s end @@ -149,6 +149,10 @@ module ActionDispatch controller = [@scope[:module], controller].compact.join("/").presence end + if controller.is_a?(String) && controller =~ %r{\A/} + raise ArgumentError, "controller name should not start with a slash" + end + controller = controller.to_s unless controller.is_a?(Regexp) action = action.to_s unless action.is_a?(Regexp) |