зеркало из https://github.com/github/ruby.git
* lib/cgi/util.rb(CGI.escapeHTML): performance improvement.
thank you @bbxiao1 via https://github.com/ruby/ruby/pull/333 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e82f5f7ddb
Коммит
e26fe81b0b
|
@ -42,7 +42,8 @@ module CGI::Util
|
|||
# # => "Usage: foo \"bar\" <baz>"
|
||||
def unescapeHTML(string)
|
||||
enc = string.encoding
|
||||
if [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].include?(enc)
|
||||
return string unless string.include? '&'
|
||||
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)
|
||||
when 'apos' then "'".encode(enc)
|
||||
|
|
Загрузка…
Ссылка в новой задаче