lib/html2doc/mime.rb in html2doc-0.9.1 vs lib/html2doc/mime.rb in html2doc-0.9.2

- old
+ new

@@ -91,11 +91,12 @@ 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"]) + local_filename = %r{^([A-Z]:)?/}.match(i["src"]) ? i["src"] : + 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) end @@ -115,10 +116,11 @@ !(%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]}") + old_filename = %r{^([A-Z]:)?/}.match(m[:src]) ? m[:src] : File.join(localdir, m[:src]) + FileUtils.cp old_filename, File.join(dir, "#{mkuuid}.#{m2[:suffix]}") a[1].sub!(%r{ src=['"](?<src>[^"']+)['"]}, " src='#{new_filename}'") end a.join end