[#70843] Re: [ruby-cvs:58952] hsbt:r51801 (trunk): * lib/rubygems: Update to RubyGems HEAD(fe61e4c112). — Eric Wong <normalperson@...>
hsbt@ruby-lang.org wrote:
3 messages
2015/09/17
[ruby-core:70660] [Ruby trunk - Bug #11506] [Open] Changed behavior of URI.unescape between 2.1.5 and 2.2.3
From:
okkez000@...
Date:
2015-09-04 07:48:01 UTC
List:
ruby-core #70660
Issue #11506 has been reported by okkez _.
----------------------------------------
Bug #11506: Changed behavior of URI.unescape between 2.1.5 and 2.2.3
https://bugs.ruby-lang.org/issues/11506
* Author: okkez _
* Status: Open
* Priority: Normal
* Assignee:=20
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Changed behavior of URI.unescape between 2.1.5 and 2.2.3. Why?
Is this change intended or not?
It breaks my application.
But I will use `CGI.unescape` for my application, for now.
My test script here.
```ruby
require "uri"
require "cgi/util"
URL =3D "http://example.com:80/?foo=3Dbar&baz=3Dqux&%E3%81%BB%E3%81%92=3D%E=
3%82%82%E3%81%92"
url =3D URI.parse(URL)
puts "-----------URI----------------"
url.query.split('&').each do |pair|
key, value =3D pair.split('=3D', 2).map{|v| URI.unescape(v) }
p [key, key.encoding]
p [value, value.encoding]
end
puts "-----------CGI----------------"
url.query.split('&').each do |pair|
key, value =3D pair.split('=3D', 2).map{|v| CGI.unescape(v) }
p [key, key.encoding]
p [value, value.encoding]
end
# erb doesn't have unescape method
```
Ruby 2.1.5
```text
-----------URI----------------
["foo", #<Encoding:UTF-8>]
["bar", #<Encoding:UTF-8>]
["baz", #<Encoding:UTF-8>]
["qux", #<Encoding:UTF-8>]
["=E3=81=BB=E3=81=92", #<Encoding:UTF-8>]
["=E3=82=82=E3=81=92", #<Encoding:UTF-8>]
-----------CGI----------------
["foo", #<Encoding:UTF-8>]
["bar", #<Encoding:UTF-8>]
["baz", #<Encoding:UTF-8>]
["qux", #<Encoding:UTF-8>]
["=E3=81=BB=E3=81=92", #<Encoding:UTF-8>]
["=E3=82=82=E3=81=92", #<Encoding:UTF-8>]
```
Ruby 2.2.3
```
$ ruby a.rb
-----------URI----------------
["foo", #<Encoding:US-ASCII>]
["bar", #<Encoding:US-ASCII>]
["baz", #<Encoding:US-ASCII>]
["qux", #<Encoding:US-ASCII>]
["\xE3\x81\xBB\xE3\x81\x92", #<Encoding:US-ASCII>]
["\xE3\x82\x82\xE3\x81\x92", #<Encoding:US-ASCII>]
-----------CGI----------------
["foo", #<Encoding:UTF-8>]
["bar", #<Encoding:UTF-8>]
["baz", #<Encoding:UTF-8>]
["qux", #<Encoding:UTF-8>]
["=E3=81=BB=E3=81=92", #<Encoding:UTF-8>]
["=E3=82=82=E3=81=92", #<Encoding:UTF-8>]
```
--=20
https://bugs.ruby-lang.org/