Skip to content

Commit

Permalink
resolves #467 fix embedding of remote images (PR #468)
Browse files Browse the repository at this point in the history
- fix use of invalid variable name
- autoload OpenURI before reading image
- fix duplicate forward slash in resolved path
  • Loading branch information
mojavelinux authored Jun 24, 2016
1 parent e3ccd35 commit a3dbd9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ def resolve_imagesdir doc
if (imagesdir = doc.attr 'imagesdir').nil_or_empty? || (imagesdir = imagesdir.chomp '/') == '.'
nil
else
%(#{imagesdir}/)
imagesdir
end
end

Expand All @@ -2408,7 +2408,7 @@ def resolve_image_path node, image_path = nil, image_type = nil
image_type ||= ::Asciidoctor::Image.image_type image_path
# handle case when image is a URI
if (node.is_uri? image_path) || (imagesdir && (node.is_uri? imagesdir) &&
(image_path = (node.normalize_web_path image_path, image_base_uri, false)))
(image_path = (node.normalize_web_path image_path, imagesdir, false)))
unless doc.attr? 'allow-uri-read'
unless scratch?
warn %(asciidoctor: WARNING: allow-uri-read is not enabled; cannot embed remote image: #{image_path})
Expand All @@ -2417,6 +2417,8 @@ def resolve_image_path node, image_path = nil, image_type = nil
end
if doc.attr? 'cache-uri'
Helpers.require_library 'open-uri/cached', 'open-uri-cached' unless defined? ::OpenURI::Cache
else
::OpenURI
end
tmp_image = ::Tempfile.new ['image-', %(.#{image_type})]
tmp_image.binmode if (binary = image_type != 'svg')
Expand Down

0 comments on commit a3dbd9a

Please sign in to comment.