aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 5f54ea130b..310e98f584 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -30,9 +30,9 @@ module ActionDispatch
controller = controller req
res = controller.make_response! req
dispatch(controller, params[:action], req, res)
- rescue NameError => e
+ rescue ActionController::RoutingError
if @raise_on_name_error
- raise ActionController::RoutingError, e.message, e.backtrace
+ raise
else
return [404, {'X-Cascade' => 'pass'}, []]
end
@@ -42,6 +42,8 @@ module ActionDispatch
def controller(req)
req.controller_class
+ rescue NameError => e
+ raise ActionController::RoutingError, e.message, e.backtrace
end
def dispatch(controller, action, req, res)
@@ -279,8 +281,17 @@ module ActionDispatch
helper = UrlHelper.create(route, opts, route_key, url_strategy)
mod.module_eval do
define_method(name) do |*args|
- options = nil
- options = args.pop if args.last.is_a? Hash
+ last = args.last
+ options = case last
+ when Hash
+ args.pop
+ when ActionController::Parameters
+ if last.permitted?
+ args.pop.to_h
+ else
+ raise ArgumentError, "Generating a URL from non sanitized request parameters is insecure!"
+ end
+ end
helper.call self, args, options
end
end
@@ -371,10 +382,6 @@ module ActionDispatch
end
def eval_block(block)
- if block.arity == 1
- raise "You are using the old router DSL which has been removed in Rails 3.1. " <<
- "Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/"
- end
mapper = Mapper.new(self)
if default_scope
mapper.with_default_scope(default_scope, &block)