mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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`.
2d90e9b010
This commit is contained in:
parent
b7644a2311
commit
217fdbf9aa
2 changed files with 4 additions and 4 deletions
|
@ -27,5 +27,7 @@ Gem::Specification.new do |spec|
|
|||
spec.executables = ['erb']
|
||||
spec.require_paths = ['lib']
|
||||
|
||||
spec.add_dependency 'cgi'
|
||||
spec.required_ruby_version = ">= 2.7.0"
|
||||
|
||||
spec.add_dependency 'cgi', '>= 0.3.3'
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue