This project is archived and is in readonly mode.

#4896 open
Igor

i18n routes can't be recognized

Reported by Igor | June 18th, 2010 @ 06:50 AM | in 3.0.6

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-...

Comments and changes to this ticket

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>

Pages