summaryrefslogtreecommitdiff
path: root/lib/feed2imap
diff options
context:
space:
mode:
authorAntonio Terceiro <terceiro@softwarelivre.org>2015-06-09 14:19:56 -0300
committerAntonio Terceiro <terceiro@softwarelivre.org>2015-06-09 14:20:25 -0300
commita34999ec51d9e2ce7bc2358c64de92a59db53213 (patch)
treef69b20f66244c298b957db4cd5fed8b202c75d51 /lib/feed2imap
parenta04ea6ef85105bf3bb0eaa0774a312b76acb5c3f (diff)
downloadfeed2imap-a34999ec51d9e2ce7bc2358c64de92a59db53213.tar.gz
feed2imap-a34999ec51d9e2ce7bc2358c64de92a59db53213.tar.bz2
feed2imap-a34999ec51d9e2ce7bc2358c64de92a59db53213.zip
itemtomail: embed images using data: URLsHEADmaster
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/itemtomail.rb20
1 files changed, 2 insertions, 18 deletions
diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb
index 455a136..55bf9d8 100644
--- a/lib/feed2imap/itemtomail.rb
+++ b/lib/feed2imap/itemtomail.rb
@@ -100,24 +100,8 @@ def item_to_mail(config, item, id, updated, from = 'Feed2Imap', inline_images =
# $2 contains url, $3 the image name, $4 the image extension
begin
fetcher = HTTPFetcher.new
- image = Base64.encode64(fetcher.fetch($2, Time.at(0)).chomp) + "\n"
- cid = "#{Digest::MD5.hexdigest($2)}@#{config.hostname}"
- if not cids.include?(cid)
- cids << cid
- imgpart = RMail::Message.new
- imgpart.header.set('Content-ID', "<#{cid}>")
- type = $4
- type = 'jpeg' if type.downcase == 'jpg' # hack hack hack
- imgpart.header.set('Content-Type', "image/#{type}", 'name' => $3)
- imgpart.header.set('Content-Disposition', 'attachment', 'filename' => $3)
- imgpart.header.set('Content-Transfer-Encoding', 'base64')
- imgpart.body = image
- imgs << imgpart
- end
- # now to specify what to replace with
- newtag = "#{$1}src=\"cid:#{cid}\"#{$5}"
- #print "#{cid}: Replacing '#{$&}' with '#{newtag}'...\n"
- newtag
+ image = Base64.encode64(fetcher.fetch($2, Time.at(0)).chomp)
+ "#{$1}src=\"data:image/#{$4};base64,#{image}\"#{$5}"
rescue
#print "Error while fetching image #{$2}: #{$!}...\n"
$& # don't modify on exception