diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-08-06 18:03:55 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-05 13:44:38 +0200 |
commit | ca3936dbd691538d97d8dbe2bc1d64c21dc7db0e (patch) | |
tree | 753c05d2e75034dd34a09b34c0328ea8b48d8099 /actionpack/lib | |
parent | c15bb4901b4c33667d56ad4a2ffbeaa3fb0f9b88 (diff) | |
download | rails-ca3936dbd691538d97d8dbe2bc1d64c21dc7db0e.tar.gz rails-ca3936dbd691538d97d8dbe2bc1d64c21dc7db0e.tar.bz2 rails-ca3936dbd691538d97d8dbe2bc1d64c21dc7db0e.zip |
Ported missing functionality from Rails 2.3.x, raise error on wrong regexps in :constraints in routes
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d53c10e5f3..fdcfe26781 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -113,6 +113,15 @@ module ActionDispatch @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 end end |