File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
1414 spec . summary = %q{An easy to use but powerful templating system for Ruby.}
1515 spec . description = %q{An easy to use but powerful templating system for Ruby.}
1616 spec . homepage = 'https://github.com/ruby/erb'
17- spec . required_ruby_version = Gem ::Requirement . new ( '>= 2.5.0' )
1817 spec . licenses = [ 'Ruby' , 'BSD-2-Clause' ]
1918
2019 spec . metadata [ 'homepage_uri' ] = spec . homepage
@@ -27,10 +26,11 @@ Gem::Specification.new do |spec|
2726 spec . executables = [ 'erb' ]
2827 spec . require_paths = [ 'lib' ]
2928
29+ spec . required_ruby_version = '>= 3.2.0'
30+
3031 if RUBY_ENGINE == 'jruby'
3132 spec . platform = 'java'
3233 else
33- spec . required_ruby_version = '>= 2.7.0'
3434 spec . extensions = [ 'ext/erb/escape/extconf.rb' ]
3535 end
3636end
Original file line number Diff line number Diff line change 1212#
1313# You can redistribute it and/or modify it under the same terms as Ruby.
1414
15- require 'cgi/escape'
1615require 'erb/version'
1716require 'erb/compiler'
1817require 'erb/def_method'
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ # Load CGI.escapeHTML and CGI.escapeURIComponent.
4+ # CRuby:
5+ # cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 3.5+ stdlib have 'cgi/escape' and CGI.escapeHTML.
6+ # cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 3.5+ stdlib have CGI.escapeURIComponent.
7+ # JRuby: cgi.gem has a Java extension 'cgi/escape'.
8+ # TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
9+ require 'cgi/escape'
10+
311begin
412 # We don't build the C extension for JRuby, TruffleRuby, and WASM
513 if $LOAD_PATH. resolve_feature_path ( 'erb/escape' )
@@ -53,8 +61,16 @@ module ERB::Util
5361 #
5462 # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
5563 #
56- def url_encode ( s )
57- CGI . escapeURIComponent ( s . to_s )
64+ if CGI . respond_to? ( :escapeURIComponent )
65+ def url_encode ( s )
66+ CGI . escapeURIComponent ( s . to_s )
67+ end
68+ else # cgi.gem <= v0.3.2
69+ def url_encode ( s )
70+ s . to_s . b . gsub ( /[^a-zA-Z0-9_\- .~]/n ) do |m |
71+ sprintf ( "%%%02X" , m . unpack1 ( "C" ) )
72+ end
73+ end
5874 end
5975 alias u url_encode
6076 module_function :u
You can’t perform that action at this time.
0 commit comments