9a1c61d99b59a07a720984e8a40bdedd78e32be5
[feedcatcher.git] / vendor / rails / activesupport / lib / active_support / core_ext / uri.rb
1 if RUBY_VERSION >= '1.9'
2 require 'uri'
3
4 str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
5 str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding)
6
7 unless str == URI.unescape(URI.escape(str))
8 URI::Parser.class_eval do
9 remove_method :unescape
10 def unescape(str, escaped = @regexp[:ESCAPED])
11 enc = (str.encoding == Encoding::US_ASCII) ? Encoding::UTF_8 : str.encoding
12 str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc)
13 end
14 end
15 end
16 end