summaryrefslogtreecommitdiff
path: root/lib/cgi/util.rb
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 13:39:13 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 13:39:13 +0000
commitfc6d58ccc469e07e7a2ef89942014a23303206eb (patch)
tree9bd3df2948e7fcd36f5d118eebe63f4aac48ec8a /lib/cgi/util.rb
parent74dcda0d418c5a5eb27047cd0e4a2bf04b637834 (diff)
* 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
Diffstat (limited to 'lib/cgi/util.rb')
-rw-r--r--lib/cgi/util.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index 7be3e92577c..9f8a63ac92a 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -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)