This project is archived and is in readonly mode.

#2574 ✓resolved

Routing: double escape url segments

Reported by edbond | April 28th, 2009 @ 11:35 AM

URL can have encoded utf-8 chars like:

To match such routes I use (routes.rb): URI.escape("/Карта--:title--:id"), ...

rails double encodes static segments and url_for generate incorrect links: % escaped to %2D and we get


instead of


This patch adds '%' to RESERVED_PCHAR so urls doesn't encoded double. Test included.

Comments and changes to this ticket

  • edbond

    edbond May 19th, 2009 @ 01:12 PM

    • Assigned user changed from “Yehuda Katz (wycats)” to “josh”
  • josh

    josh May 25th, 2009 @ 05:29 PM

    • State changed from “new” to “open”
    • Milestone cleared.
  • Repository

    Repository May 27th, 2009 @ 09:02 PM

    • State changed from “open” to “resolved”
  • Dan Byström

    Dan Byström October 6th, 2009 @ 04:59 PM

    I suspecting that the routing string (/Карта--:title--:id) shouldn't be escaped. It makes sense to think that the rails developers escapes the route stings for us. URI.escape("/Карта--:title--:id"), ... it should be "/Карта--:title--:id", ... The unescaped code works just fine when I host/run my application with Apache+Phusion Passenger. However, in my development environment (Aptana Studio or the script/server command) then I have to escape all my routes and apply your routing_uri_escape.patch.

    Since I'm a newbe I have no clue what causes this escape bug. Still, I'm quite sure that the escape bug needs a second check.

  • Dan Byström

    Dan Byström February 11th, 2010 @ 06:55 AM

    I think this is how you want to solve this problem.

    # config/routes.rb "/Карта--:title--:id", :controller => 'foo', :action => 'bar'
    # config/initializers/new_rails_defaults.rb
    module ActionController
      module Routing
        class RouteSet
          def recognize(request)
            params = recognize_path(URI.unescape(request.path), extract_request_environment(request))
            request.path_parameters = params.with_indifferent_access

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=""></a>


Referenced by