rails/rails — pull request #14629 by edogawaconan (2014-04-07 06:43:16+00:00)
Title: Always escape string passed to url helper.

Makes it clear that anything passed with the helper must not be percent encoded.

Fixes previous behavior which tricks people into believing passing non-percent-encoded will generate a proper percent-encoded path while in reality it doesn't ('%' isn't escaped).

The intention is nice but the heuristic is broken. As of current implementation, passing a string as `:id` or anything part of path requires either `id.gsub('%', '%25')` or `URI.encode(id)` otherwise there's chance the generated url is broken. (at which point the escape done in helper is useless)

I can think of three possible solutions:

1. this one
2. assume everything is percent-encoded
3. try decoding the string and encode if decoding fails

Sorry for reporting this at bad timing.