summaryrefslogtreecommitdiff
path: root/lib/cgi/util.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-21 04:57:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-21 04:57:57 +0000
commitd463c492bc983b0ac1f6e760695b3739767dd668 (patch)
tree279691113527e6d4a27fb31c6eea98975e873a44 /lib/cgi/util.rb
parent1b7109e11a6690521b810bae8a948c24253cdd3e (diff)
cgi/escape: Optimize CGI.unescape
* cgi/escape/escape.c: Optimize CGI.unescape performance by C ext for ASCII-compatible encodings. [Fix GH-1250] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi/util.rb')
-rw-r--r--lib/cgi/util.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index d2657ab9810..7968c9326e9 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -16,6 +16,10 @@ module CGI::Util
# string = CGI::unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def unescape(string,encoding=@@accept_charset)
+ _unescape(string,encoding)
+ end
+
+ private def _unescape(string, encoding)
str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do |m|
[m.delete('%')].pack('H*')
end.force_encoding(encoding)