aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAshe Connor <ashe@kivikakk.ee>2018-03-07 11:41:46 +1100
committerAshe Connor <ashe@kivikakk.ee>2018-03-07 12:58:02 +1100
commite52ab312069a9af0c37c1666141752f3bc805054 (patch)
tree4ba840a506256a5c7c3ebcabda9e2031d1c5af6e /activesupport/test
parente126078a0e013acfe0a397a8dad33b2c9de78732 (diff)
downloadrails-e52ab312069a9af0c37c1666141752f3bc805054.tar.gz
rails-e52ab312069a9af0c37c1666141752f3bc805054.tar.bz2
rails-e52ab312069a9af0c37c1666141752f3bc805054.zip
URI.unescape handles mixed Unicode/escaped input
Previously, URI.enscape could handle Unicode input (without any actual escaped characters), or input with escaped characters (but no actual Unicode characters) - not both. URI.unescape("\xe3\x83\x90") # => "バ" URI.unescape("%E3%83%90") # => "バ" URI.unescape("\xe3\x83\x90%E3%83%90") # => # Encoding::CompatibilityError We need to let `gsub` handle this for us, and then force back to the original encoding of the input. The result String will be mangled if the percent-encoded characters don't conform to the encoding of the String itself, but that goes without saying. Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/uri_ext_test.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/uri_ext_test.rb b/activesupport/test/core_ext/uri_ext_test.rb
index 8816b0d392..c0686bc720 100644
--- a/activesupport/test/core_ext/uri_ext_test.rb
+++ b/activesupport/test/core_ext/uri_ext_test.rb
@@ -9,6 +9,6 @@ class URIExtTest < ActiveSupport::TestCase
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
parser = URI.parser
- assert_equal str, parser.unescape(parser.escape(str))
+ assert_equal str + str, parser.unescape(str + parser.escape(str).encode(Encoding::UTF_8))
end
end