From 55742dce2d30534faa95551c7904bbf660b4835b Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 24 Aug 2008 02:27:47 +0000 Subject: [PATCH] * lib/cgi.rb (CGI::unescapeHTML): consider ISO-8859-1. [ruby-dev:35936] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/cgi.rb | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc23438d6a..a9411f6256 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Aug 24 11:26:54 2008 NARUSE, Yui + + * lib/cgi.rb (CGI::unescapeHTML): consider ISO-8859-1. + [ruby-dev:35936] + Sun Aug 24 10:55:00 2008 NARUSE, Yui * enc/emacs_mule.c: support Emacs/Mule internal encoding. diff --git a/lib/cgi.rb b/lib/cgi.rb index ab57fbdcd0..52137d85ed 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -396,18 +396,20 @@ class CGI when 'gt' then '>' when 'lt' then '<' when /\A#0*(\d+)\z/ - if enc == Encoding::UTF_8 - $1.to_i.chr(enc) - elsif $1.to_i < 128 && asciicompat - $1.to_i.chr + n = $1.to_i + if enc == Encoding::UTF_8 or + enc == Encoding::ISO_8859_1 && n < 256 or + asciicompat && n < 128 + n.chr(enc) else "&##{$1};" end when /\A#x([0-9a-f]+)\z/i - if enc == Encoding::UTF_8 - $1.hex.chr(enc) - elsif $1.hex < 128 && asciicompat - $1.hex.chr + n = $1.hex + if enc == Encoding::UTF_8 or + enc == Encoding::ISO_8859_1 && n < 256 or + asciicompat && n < 128 + n.chr(enc) else "&#x#{$1};" end