FIX: Inline secure images with duplicated names (#13926)

Inlining secure images with the same name was not possible because they
were indexed by filename. If an email contained two files with the same
name, only the first image was used for both of them. The other file
was still attached to the email.
This commit is contained in:
Bianca Nenciu
2021-08-03 18:58:34 +03:00
committed by GitHub
parent 413de9361f
commit 52520638ca
4 changed files with 27 additions and 15 deletions

View File

@@ -26,7 +26,8 @@ module Email
class Sender
def initialize(message, email_type, user = nil)
@message = message
@message = message
@message_attachments_index = {}
@email_type = email_type
@user = user
end
@@ -240,7 +241,7 @@ module Email
# Embeds any of the secure images that have been attached inline,
# removing the redaction notice.
if SiteSetting.secure_media_allow_embed_images_in_emails
style.inline_secure_images(@message.attachments)
style.inline_secure_images(@message.attachments, @message_attachments_index)
end
@message.html_part.body = style.to_s
@@ -328,6 +329,7 @@ module Email
Discourse.store.download(attached_upload).path
end
@message_attachments_index[original_upload.sha1] = @message.attachments.size
@message.attachments[original_upload.original_filename] = File.read(path)
email_size += File.size(path)
rescue => e