1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/cgi/util.rb (CGI::unescape): bugfix to unescape the multibyte

string. Thanks nobu and tDiary dev members. [Bug #3909]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
xibbar 2010-10-13 13:39:13 +00:00
parent 74dcda0d41
commit fc6d58ccc4
3 changed files with 7 additions and 1 deletions

View file

@ -14,7 +14,7 @@ class CGI
# string = CGI::unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def CGI::unescape(string,encoding=@@accept_charset)
str=string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
str=string.tr('+', ' ').force_encoding(Encoding::ASCII_8BIT).gsub(/((?:%[0-9a-fA-F]{2})+)/) do
[$1.delete('%')].pack('H*')
end.force_encoding(encoding)
str.valid_encoding? ? str : str.force_encoding(string.encoding)