lib/isodoc/function/utils.rb in isodoc-1.4.1 vs lib/isodoc/function/utils.rb in isodoc-1.4.2
- old
+ new
@@ -159,11 +159,11 @@
template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h)
.gsub('<', '<').gsub('>', '>').gsub('&', '&')
end
def save_dataimage(uri, _relative_dir = true)
- %r{^data:image/(?<imgtype>[^;]+);base64,(?<imgdata>.+)$} =~ uri
+ %r{^data:(image|application)/(?<imgtype>[^;]+);base64,(?<imgdata>.+)$} =~ uri
imgtype.sub!(/\+[a-z0-9]+$/, '') # svg+xml
imgtype = 'png' unless /^[a-z0-9]+$/.match imgtype
Tempfile.open(['image', ".#{imgtype}"]) do |f|
f.binmode
f.write(Base64.strict_decode64(imgdata))
@@ -171,10 +171,10 @@
f.path
end
end
def image_localfile(i)
- if /^data:image/.match? i['src']
+ if /^data:/.match? i['src']
save_dataimage(i['src'], false)
elsif %r{^([A-Z]:)?/}.match? i['src']
i['src']
else
File.join(@localdir, i['src'])