summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--Gemfile1
-rw-r--r--asciidoctor.gemspec2
-rw-r--r--lib/asciidoctor.rb1
-rw-r--r--lib/asciidoctor/abstract_node.rb12
5 files changed, 9 insertions, 8 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 30986609..5fa8837a 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -45,6 +45,7 @@ Compliance::
* Update stylesheet to use break-after in place of page-break-before/after/inside (#3466)
* Drop support for Ruby < 2.7 and JRuby < 9.2
* Update latest JRuby in CI workflow to 9.4.2.0
+ * Remove use of base64 library to prevent warning in Ruby >= 3.3 (#4561)
Improvements::
diff --git a/Gemfile b/Gemfile
index a54f0535..e2246287 100644
--- a/Gemfile
+++ b/Gemfile
@@ -23,6 +23,7 @@ group :development do
elsif (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.7.0')
gem 'nokogiri', '~> 1.13.0'
end
+ gem 'minitest', '~> 5.14.0' if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.6.0')
end
group :docs do
diff --git a/asciidoctor.gemspec b/asciidoctor.gemspec
index 99b73eef..9f8a5ec4 100644
--- a/asciidoctor.gemspec
+++ b/asciidoctor.gemspec
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
# erubi is needed for testing alternate eRuby impls
s.add_development_dependency 'erubi', '~> 1.10.0'
s.add_development_dependency 'haml', '~> 6.1.0', '!= 6.1.2'
- s.add_development_dependency 'minitest', '~> 5.14.0'
+ s.add_development_dependency 'minitest', '~> 5.22.0'
s.add_development_dependency 'nokogiri', '~> 1.14.0'
s.add_development_dependency 'rake', '~> 12.3.0'
s.add_development_dependency 'slim', '~> 4.1.0'
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 18b6743b..08a5db02 100644
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -7,7 +7,6 @@ if RUBY_ENGINE == 'opal'
# this require is satisfied by the Asciidoctor.js build; it augments the Ruby environment for Asciidoctor.js
require 'asciidoctor/js'
else
- autoload :Base64, 'base64'
require 'cgi/util'
autoload :OpenURI, 'open-uri'
autoload :Pathname, 'pathname'
diff --git a/lib/asciidoctor/abstract_node.rb b/lib/asciidoctor/abstract_node.rb
index a60ab795..07ad0291 100644
--- a/lib/asciidoctor/abstract_node.rb
+++ b/lib/asciidoctor/abstract_node.rb
@@ -355,8 +355,8 @@ class AbstractNode
#
# First, and foremost, the target image path is cleaned if the document safe mode level
# is set to at least SafeMode::SAFE (a condition which is true by default) to prevent access
- # to ancestor paths in the filesystem. The image data is then read and converted to
- # Base64. Finally, a data URI is built which can be used in an image tag.
+ # to ancestor paths in the filesystem. The image data is then read and converted to base64.
+ # Finally, a data URI is built which can be used in an image tag.
#
# target_image - A String path to the target image
# asset_dir_key - The String attribute key used to lookup the directory where
@@ -377,8 +377,8 @@ class AbstractNode
end
if ::File.readable? image_path
- # NOTE base64 is autoloaded by reference to ::Base64
- %(data:#{mimetype};base64,#{::Base64.strict_encode64 ::File.binread image_path})
+ # NOTE pack 'm0' is equivalent to Base64.strict_encode64
+ %(data:#{mimetype};base64,#{[(::File.binread image_path)].pack 'm0'})
else
logger.warn %(image to embed not found or not readable: #{image_path})
%(data:#{mimetype};base64,)
@@ -411,8 +411,8 @@ class AbstractNode
begin
mimetype, bindata = ::OpenURI.open_uri(image_uri, URI_READ_MODE) {|f| [f.content_type, f.read] }
- # NOTE base64 is autoloaded by reference to ::Base64
- %(data:#{mimetype};base64,#{::Base64.strict_encode64 bindata})
+ # NOTE pack 'm0' is equivalent to Base64.strict_encode64
+ %(data:#{mimetype};base64,#{[bindata].pack 'm0'})
rescue
logger.warn %(could not retrieve image data from URI: #{image_uri})
image_uri