From: nagachika00@... Date: 2015-10-07T07:46:10+00:00 Subject: [ruby-core:71008] [Ruby trunk - Bug #11506] [Assigned] Changed behavior of URI.unescape between 2.1.5 and 2.2.3 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", #] ["bar", #] ["baz", #] ["qux", #] ["������", #] ["������", #] -----------CGI---------------- ["foo", #] ["bar", #] ["baz", #] ["qux", #] ["������", #] ["������", #] ``` Ruby 2.2.3 ``` $ ruby a.rb -----------URI---------------- ["foo", #] ["bar", #] ["baz", #] ["qux", #] ["\xE3\x81\xBB\xE3\x81\x92", #] ["\xE3\x82\x82\xE3\x81\x92", #] -----------CGI---------------- ["foo", #] ["bar", #] ["baz", #] ["qux", #] ["������", #] ["������", #] ``` -- https://bugs.ruby-lang.org/