Issue #11506 has been updated by Tomoyuki Chikanaga.

Status changed from Open to Assigned
Assignee set to Yui NARUSE

It is related with r46491 for [Feature #2542] (support RFC 3986)?

I think it is intended change.
naruse san, how do you think?

----------------------------------------
Bug #11506: Changed behavior of URI.unescape between 2.1.5 and 2.2.3
https://bugs.ruby-lang.org/issues/11506#change-54383

* Author: okkez _
* Status: Assigned
* Priority: Normal
* Assignee: Yui NARUSE
* 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 = "http://example.com:80/?foo=bar&baz=qux&%E3%81%BB%E3%81%92=%E3%82%82%E3%81%92"

url = URI.parse(URL)

puts "-----------URI----------------"

url.query.split('&').each do |pair|
  key, value = pair.split('=', 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 = pair.split('=', 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>]
["ほげ", #<Encoding:UTF-8>]
["もげ", #<Encoding:UTF-8>]
-----------CGI----------------
["foo", #<Encoding:UTF-8>]
["bar", #<Encoding:UTF-8>]
["baz", #<Encoding:UTF-8>]
["qux", #<Encoding:UTF-8>]
["ほげ", #<Encoding:UTF-8>]
["もげ", #<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>]
["ほげ", #<Encoding:UTF-8>]
["もげ", #<Encoding:UTF-8>]
```




-- 
https://bugs.ruby-lang.org/