summaryrefslogtreecommitdiff
path: root/lib/erb.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2022-10-25 18:39:56 +0200
committergit <svn-admin@ruby-lang.org>2022-10-25 16:40:05 +0000
commit217fdbf9aa6dd850eace9f10c9a74bcec8b510e2 (patch)
tree06bdcd49fca3f87139005cec4dc905681b12fb50 /lib/erb.rb
parentb7644a231100b1e1b70af528f9629d2e39572087 (diff)
[ruby/erb] url_encode: use CGI.escapeURIComponent
(https://github.com/ruby/erb/pull/23) Ref: https://github.com/ruby/cgi/pull/26 This native implementation is much faster and available in `cgi 0.3.3`. https://github.com/ruby/erb/commit/2d90e9b010
Diffstat (limited to 'lib/erb.rb')
-rw-r--r--lib/erb.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index 0e42425a60..962eeb6963 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -1019,9 +1019,7 @@ class ERB
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
#
def url_encode(s)
- s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m|
- sprintf("%%%02X", m.unpack1("C"))
- }
+ CGI.escapeURIComponent(s.to_s)
end
alias u url_encode
module_function :u