Browse files

Restore previous behavior of normalize_path

While this is going to break what we were trying to fix in GitHub code,
ultimately this returns Rails 4.2 to it's previous behavior before we
changed Rack in rack/rack@c7ee52f.

From Rack the params should be ASCII, but because Ruby 1.9.3, 2.1.0,
2.2.2, and 2.4.0 all convert this line to UTF8 because the code is
combining an ASCII encoding with a string which is UTF8 so UTF8 wins.

In Ruby 2.0.0 however, the encoding of the original string was
maintained. So when I reverted the change made in #29062 on Rails 4.2
Ruby 2.0.0 was still failing. By forcing the encoding to UTF8 we are
returning the code to the previous behavior.

On master we handle this elsewhere but since Rails 4.2 does not define
`binary_params_for?` we can't implement the change required there.
  • Loading branch information...
eileencodes committed Aug 2, 2017
1 parent 47f8eb9 commit a7d49ef78c36df2d1ca876451f30915ada1079a5
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/journey/router/utils.rb
@@ -13,7 +13,7 @@ class Utils # :nodoc:
# normalize_path("") # => "/"
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
path = "/#{path}"
path = "/#{path}".force_encoding(Encoding::UTF_8)
path.sub!(%r{/+\Z}, '')
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }

0 comments on commit a7d49ef

Please sign in to comment.