diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-02 08:07:18 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-02 08:07:18 +0000 |
commit | 51f6ed8161442265448f5b6c462a3e442cf7fcb1 (patch) | |
tree | 81b176730898ac4e43d6d2f8261f7dacbd0e19e7 | |
parent | ebea538a9609fd0b3589a5b59a9173b6905425ec (diff) |
merges r29484 from trunk into ruby_1_9_2.
--
* 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/branches/ruby_1_9_2@30044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/cgi/util.rb | 2 | ||||
-rw-r--r-- | test/cgi/test_cgi_util.rb | 1 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Wed Oct 13 22:32:34 2010 Takeyuki FUJIOKA <xibbar@ruby-lang.org> + + * lib/cgi/util.rb (CGI::unescape): bugfix to unescape the multibyte + string. Thanks nobu and tDiary dev members. [Bug #3909] + Tue Oct 12 23:58:19 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * win32/win32.c (rb_w32_open_osfhandle, rb_w32_wopen, rb_w32_pipe): diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb index 7be3e92577..9f8a63ac92 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) diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index 479df68159..71e8beac3d 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -27,6 +27,7 @@ class CGIUtilTest < Test::Unit::TestCase def test_cgi_unescape assert_equal(@str1, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93')) assert_equal(@str1.encoding, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93').encoding) if defined?(::Encoding) + assert_equal("\u{30E1 30E2 30EA 691C 7D22}", CGI.unescape("\u{30E1 30E2 30EA}%E6%A4%9C%E7%B4%A2")) end def test_cgi_pretty @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 74 +#define RUBY_PATCHLEVEL 75 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |