summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/erb/util.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/erb/util.rb b/lib/erb/util.rb
index c24a175199..0c1e7482a8 100644
--- a/lib/erb/util.rb
+++ b/lib/erb/util.rb
@@ -4,10 +4,13 @@
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
# Rails will not monkey-patch ERB::Escape#html_escape.
begin
- require 'erb/escape'
-rescue LoadError # JRuby can't load .so
+ # 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 # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
end
-unless defined?(ERB::Escape) # JRuby
+unless defined?(ERB::Escape)
module ERB::Escape
def html_escape(s)
CGI.escapeHTML(s.to_s)