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.

i18n routes can't be recognized

#4896

Rails (2.3.5 and it seems the same is with edge) with Ruby 1.9 correctly creates and stores utf-8 based routes. But when it comes to route recognition, it fails to match the route name:

map.home 'начало', controller: :home, action: :index

then
http://localhost/%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%BE
gives

No route matches "/%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%BE" with {:method=>:get}

The reason is that recognize_path does html unescape only after routes are mapped, and because of this it fails to map raw utf8 stored name against its %XX%XX equivalent.

In 2.3.5 the next patch fixes the issue:

require 'action_pack'
require 'cgi'
module ActionController::Routing
  class RouteSet
    alias_method :recognize_path_ugly, :recognize_path

    def recognize_path(path, environment)
      path = CGI::unescape(path).force_encoding('utf-8').encode(invalid: :replace)
      recognize_path_ugly(path, environment)
    end
  end
end

The problem was introduced with http://dev.rubyonrails.org/changeset/6185 which basically tried to fix another issue. Actually fixing it with the above patch will break the current behaviour of parameters unescaping, so it should be carefully considered.

The similar issue was raised which also may interfere with this problem:
https://rails.lighthouseapp.com/projects/8994/tickets/2574-routing-...

Reported by Igor · June 18th, 2010 @ 06:50 AM

State: open
Milestone: 3.0.6
Assigned to: Andrew White Andrew White
Importance: Medium

Activity

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

    With the increasing support for IDN in browsers this is probably something we want to address.

    June 27th, 2010 @ 06:10 PM

  2. Jeremy Kemper
  3. Jeremy Kemper
  4. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 16th, 2010 @ 02:42 AM

  5. Santiago Pastorino
  6. Santiago Pastorino
  7. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.0.5 to 3.0.6

    February 27th, 2011 @ 03:15 AM