Closed
Description
Ruby 3.1 changed the behavior of YAML.load to match YAML.safe_load. The open-uri/cached gem uses YAML.load to load data that includes tags, which are classified as an unsafe feature. As a result, this gem cannot load its own cached data and thus fails to retrieve the image from the cache. Asciidoctor will need to patch the gem so the integration will work when using Ruby 3.1.
Here's the patch to apply:
def patch_open_uri_cached
return unless (::YAML.respond_to? :unsafe_load) && !(::OpenURI::Cache.const_defined? :YAML, false)
::OpenURI::Cache.const_set :YAML, (::Module.new do
define_singleton_method :dump, &(::YAML.method :dump)
define_singleton_method :load, &(::YAML.method :unsafe_load)
end)
end
This patch injects an unsafe YAML implementation into the scope of the gem so it continues to work as it did before.