summaryrefslogtreecommitdiff
path: root/lib/cgi/util.rb
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-19 21:11:52 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-19 21:11:52 +0000
commit69ea68cc21f6539b58c08d8a122fdce3f062a1ce (patch)
tree27e27582ef3daee7c35b33bcb3afced6209822cb /lib/cgi/util.rb
parentefc53c496e3694d5050be10068c1ad16c41e53c3 (diff)
* lib/cgi/util.rb (CGI.escapeHTML): performance improvement.
thank you nagachika-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41455 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 61738139fef..71fe48abd13 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -41,8 +41,8 @@ module CGI::Util
# CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
# # => "Usage: foo \"bar\" <baz>"
def unescapeHTML(string)
- enc = string.encoding
return string unless string.include? '&'
+ enc = string.encoding
if enc != Encoding::UTF_8 && [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].include?(enc)
return string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do
case $1.encode(Encoding::US_ASCII)