From 713920f74eed65b16f777bd76f56098ea927aee0 Mon Sep 17 00:00:00 2001 From: knu Date: Thu, 15 Feb 2007 01:59:07 +0000 Subject: * lib/cgi.rb (CGI::unescapeHTML): invalid decoding for single unescaped ampersand. a patch from Tietew in [ruby-dev:30292]. fixed: [ruby-dev:30289] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/cgi.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/cgi.rb b/lib/cgi.rb index 94d92e25ae..a7cedd13aa 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -367,13 +367,13 @@ class CGI # CGI::unescapeHTML("Usage: foo "bar" <baz>") # # => "Usage: foo \"bar\" " def CGI::unescapeHTML(string) - string.gsub(/&(.*?);/n) do + string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/n) do match = $1.dup case match - when /\Aamp\z/ni then '&' - when /\Aquot\z/ni then '"' - when /\Agt\z/ni then '>' - when /\Alt\z/ni then '<' + when 'amp' then '&' + when 'quot' then '"' + when 'gt' then '>' + when 'lt' then '<' when /\A#0*(\d+)\z/n then if Integer($1) < 256 Integer($1).chr -- cgit v1.2.3