This project is archived and is in readonly mode.
Regexp ignore-case option in routes breaks params
Reported by Andrew Bloomgarden | June 9th, 2010 @ 09:07 AM | in 3.0.2
(see attached for an example app with this code)
If you have a blank app with the following controller:
class TestController < ApplicationController
def index
render :text => params.inspect
end
end
and the following in routes.rb:
get "/:foo/:bar" => 'test#index', :foo => /first/i, :bar => /second/
when going to /first/second, the expected response would have both the :foo and :bar components in it, but it actually is the following:
{"action"=>"index", "foo"=>"first", "controller"=>"test"}
The second component somehow gets swallowed. I'm not sure exactly what's going on, so hopefully we can figure this out.
Comments and changes to this ticket
-
Andrew Bloomgarden June 9th, 2010 @ 09:42 AM
- Title changed from Two regexp options in routing breaks params to Regexp ignore-case option in routes breaks params
-
DHH June 9th, 2010 @ 05:11 PM
- Milestone cleared.
- Assigned user set to josh
-
Andrew Bloomgarden June 9th, 2010 @ 11:36 PM
Alright, I believe I've found the issue. Given this in the routing test:
controller :articles do scope '/articles', :name_prefix => 'article' do scope :path => '/:title', :title => /[a-z]+/i, :as => :with_title do match '/:id', :to => :with_id end end end
the Rack::Mount::Route for article_with_title has named_captures
{:path_info=>{:title=>0, :id=>2}}
but without the ignore-case flag it has
{:path_info=>{:title=>0, :id=>1}}
Now to actually fix it…
-
Andrew Bloomgarden June 9th, 2010 @ 11:50 PM
- Tag changed from rails3 routes, bug, rails3, regression to rails3 routes, bug, rack-mount, rails3, regression
Turns out this is a rack-mount issue, so I've attached a failing test case for that.
-
Andrew Bloomgarden June 10th, 2010 @ 12:19 AM
- Tag changed from rails3 routes, bug, rack-mount, rails3, regression to rails3 routes, bug, patch, rack-mount, rails3, regression
And here's a fix. RegexpWithNamedGroups was treating (?i-mx:blah) and the like as captures.
-
Andrew Bloomgarden June 10th, 2010 @ 02:13 AM
One last patchfile, this one with an explicit test added for RegexpWithNamedGroups.
-
Andrew Bloomgarden June 10th, 2010 @ 02:30 AM
And that makes the ActionDispatch test pass, as expected.
-
José Valim June 23rd, 2010 @ 12:23 PM
- State changed from new to committed
Closing since it was already applied to Rack-Mount.
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>