diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2017-05-12 14:58:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-12 14:58:46 -0400 |
commit | 276bfa7fc6efb0cea4408fe9f97b8741737b7549 (patch) | |
tree | 0c8f2613b1c4507905a57e3b580b4e0bb4e92aca /actionpack/lib/action_dispatch | |
parent | b30760a4846d04bc48c787c95013208950906f5e (diff) | |
parent | 8607c25ba7810573733d9b37d0015154ba059f5e (diff) | |
download | rails-276bfa7fc6efb0cea4408fe9f97b8741737b7549.tar.gz rails-276bfa7fc6efb0cea4408fe9f97b8741737b7549.tar.bz2 rails-276bfa7fc6efb0cea4408fe9f97b8741737b7549.zip |
Merge pull request #29062 from eileencodes/force-encoding-to-original-string-encoding
Maintain original encoding from path
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/router/utils.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router/utils.rb b/actionpack/lib/action_dispatch/journey/router/utils.rb index e624b4c80d..6d400f3364 100644 --- a/actionpack/lib/action_dispatch/journey/router/utils.rb +++ b/actionpack/lib/action_dispatch/journey/router/utils.rb @@ -13,11 +13,13 @@ module ActionDispatch # normalize_path("") # => "/" # normalize_path("/%ab") # => "/%AB" def self.normalize_path(path) + encoding = path.encoding path = "/#{path}" path.squeeze!("/".freeze) path.sub!(%r{/+\Z}, "".freeze) path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase } path = "/" if path == "".freeze + path.force_encoding(encoding) path end |