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