diff options
-rw-r--r-- | ext/erb/escape/extconf.rb | 7 | ||||
-rw-r--r-- | lib/erb/util.rb | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/ext/erb/escape/extconf.rb b/ext/erb/escape/extconf.rb index 9dec05f2c6..c1002548ad 100644 --- a/ext/erb/escape/extconf.rb +++ b/ext/erb/escape/extconf.rb @@ -1,2 +1,7 @@ require 'mkmf' -create_makefile 'erb/escape' + +if RUBY_ENGINE == 'truffleruby' + File.write('Makefile', dummy_makefile($srcdir).join) +else + create_makefile 'erb/escape' +end 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) |