зеркало из https://github.com/github/ruby.git
[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
This commit is contained in:
Родитель
b7644a2311
Коммит
217fdbf9aa
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче