aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/core_ext/uri.rb3
-rw-r--r--activesupport/test/core_ext/uri_ext_test.rb8
2 files changed, 8 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/uri.rb b/activesupport/lib/active_support/core_ext/uri.rb
index 9a1c61d99b..ca1be8b7e9 100644
--- a/activesupport/lib/active_support/core_ext/uri.rb
+++ b/activesupport/lib/active_support/core_ext/uri.rb
@@ -4,7 +4,8 @@ if RUBY_VERSION >= '1.9'
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding)
- unless str == URI.unescape(URI.escape(str))
+ parser = URI::Parser.new
+ unless str == parser.unescape(parser.escape(str))
URI::Parser.class_eval do
remove_method :unescape
def unescape(str, escaped = @regexp[:ESCAPED])
diff --git a/activesupport/test/core_ext/uri_ext_test.rb b/activesupport/test/core_ext/uri_ext_test.rb
index 2d4f38d095..e4a242abc4 100644
--- a/activesupport/test/core_ext/uri_ext_test.rb
+++ b/activesupport/test/core_ext/uri_ext_test.rb
@@ -7,7 +7,11 @@ class URIExtTest < Test::Unit::TestCase
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding)
- assert_equal str, URI.unescape(URI.escape(str))
- assert_equal str, URI.decode(URI.escape(str))
+ if URI.const_defined?(:Parser)
+ parser = URI::Parser.new
+ assert_equal str, parser.unescape(parser.escape(str))
+ else
+ assert_equal str, URI.unescape(URI.escape(str))
+ end
end
end