From e8e7daa71a4915e3cfcf0dccc8392cdacc55866e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 13 May 2025 16:29:45 -0700 Subject: [PATCH] [ruby/erb] Reapply "Refactor the logic of require 'erb/escape' (https://github.com/ruby/erb/pull/61)" This reverts commit https://github.com/ruby/erb/commit/1c9200aab071. Now that we've bumped BASERUBY, we shouldn't need to rescue the LoadError. https://github.com/ruby/erb/commit/846b20fe0e --- lib/erb/util.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/erb/util.rb b/lib/erb/util.rb index b538e7ccb6..dc9ab3831b 100644 --- a/lib/erb/util.rb +++ b/lib/erb/util.rb @@ -8,14 +8,11 @@ # TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'. require 'cgi/escape' -begin - # We don't build the C extension for JRuby, TruffleRuby, and WASM - if $LOAD_PATH.resolve_feature_path('erb/escape') - require 'erb/escape' - end -rescue LoadError # Ruby 3.1+ doesn't raise LoadError on resolve_feature_path, but we may use Ruby 3.0 for BASERUBY here. -end -unless defined?(ERB::Escape) +# Load or define ERB::Escape#html_escape. +# We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM. +if $LOAD_PATH.resolve_feature_path('erb/escape') + require 'erb/escape' +else # ERB::Escape # # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope