Browse files

Ported missing functionality from Rails 2.3.x, raise error on wrong r…

…egexps in :constraints in routes
  • Loading branch information...
1 parent c15bb49 commit ca3936dbd691538d97d8dbe2bc1d64c21dc7db0e @drogus drogus committed Aug 6, 2010
Showing with 9 additions and 0 deletions.
  1. +9 −0 actionpack/lib/action_dispatch/routing/mapper.rb
9 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -113,6 +113,15 @@ def requirements
@requirements ||= (@options[:constraints].is_a?(Hash) ? @options[:constraints] : {}).tap do |requirements|
requirements.reverse_merge!(@scope[:constraints]) if @scope[:constraints]
@options.each { |k, v| requirements[k] = v if v.is_a?(Regexp) }
+ requirements.each do |_, requirement|
+ if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
+ raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
+ end
+ if requirement.multiline?
+ raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
+ end
+ end

3 comments on commit ca3936d


No test?

Ruby on Rails member

There is a test for that:

This commit is part of removing deprecated mapper, I just fixed it some time after the initial commit with removal.


Cool, thanks for the clarification.

Please sign in to comment.