Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Problems with POSIX character classes as routing constraints

#5509

In an Ruby on Rails 3 app before RoR 3 development has got its own stable branch I used a constraint with POSIX character classes. But since then it was broken.

The defined scope and its routes:

scope 'o~', :token => /[[:alnum:]]{40}/ do
  get ':token' => 'token#show', :as => :token
  # ...
end

In Terminal I do:

$ rake routes
(in /Users/florian/Development/takeda)
rake aborted!
premature end of char-class: /\A[[:alnum:]\Z/

Reported by Florian Aßmann · August 31st, 2010 @ 09:59 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to josh
    • Importance changed from to Low

    You're missing a do after the regexp. After I add the do then rake routes runs fine but I do get an error in route generation and recognition. It looks as though the error is in the Regin regexp analyser - it appears to be removing the closing square bracket from the character class.

    August 31st, 2010 @ 11:38 AM

  2. Andrew White
    Andrew White

    Yup, the Regin parser doesn't handle the named character class:

    >> Regin.parse(/\A[[:alnum:]]{40}\Z/).to_a
    => [#<Anchor "\\A">, #<CharacterClass "[[:alnum:]">, #<Character "]{40}">, #<Anchor "\\Z">]
    

    GH issue: http://github.com/josh/regin/issues#issue/3

    August 31st, 2010 @ 12:36 PM

  3. Andrew White
    Andrew White

    Florian, can you gem install -v=0.6.13 'rack-mount' and see if that fixes your problem - it does for me.

    August 31st, 2010 @ 04:26 PM

  4. Andrew White
    Andrew White
    • Assigned user changed from josh to José Valim

    Patch to bump rack-mount to 0.6.13 and add test case to catch any regressions.

    August 31st, 2010 @ 05:45 PM

  5. Repository
    Repository
    • State changed from open to resolved

    (from [6c3f5eb76c2277e8a8e94d8c7d8942dc2d11a3df]) Bump rack-mount to 0.6.13 and add test case for named character classes [#5509 Problems with POSIX character classes as routing constraints state:resolved]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    http://github.com/rails/rails/commit/6c3f5eb76c2277e8a8e94d8c7d8942...

    September 1st, 2010 @ 01:17 AM

  6. Repository
  7. Florian Aßmann
  8. Jeremy Kemper