lib/html2doc/mime.rb in html2doc-0.8.7 vs lib/html2doc/mime.rb in html2doc-0.8.8
- old
+ new
@@ -86,10 +86,11 @@
#docxml.xpath(IMAGE_PATH).each do |i|
docxml.traverse do |i|
next unless i.element? && %w(img v:imagedata).include?(i.name)
warnsvg(i["src"])
next if /^http/.match i["src"]
+ next if %r{^data:image/[^;]+;base64}.match i["src"]
local_filename = File.join(localdir, i["src"])
new_filename = "#{mkuuid}#{File.extname(i["src"])}"
FileUtils.cp local_filename, File.join(dir, new_filename)
i["width"], i["height"] = image_resize(i, local_filename, 680, 400)
i["src"] = File.join(File.basename(dir), new_filename)
@@ -104,10 +105,11 @@
header_image_cleanup1(a, dir, filename, localdir)
end.join
end
def self.header_image_cleanup1(a, dir, filename, localdir)
- if a.size == 2 && !(/ src="https?:/.match a[1])
+ if a.size == 2 && !(/ src="https?:/.match a[1]) &&
+ !(%r{ src="data:image/[^;]+;base64}.match a[1])
m = / src=['"](?<src>[^"']+)['"]/.match a[1]
warnsvg(m[:src])
m2 = /\.(?<suffix>\S+)$/.match m[:src]
new_filename = "file:///C:/Doc/#{filename}_files/#{mkuuid}.#{m2[:suffix]}"
FileUtils.cp File.join(localdir, m[:src]), File.join(dir, "#{mkuuid}.#{m2[:suffix]}")