mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -253,7 +253,7 @@ module Email
|
||||
@@plugin_callbacks.each { |block| block.call(@fragment, @opts) }
|
||||
end
|
||||
|
||||
def inline_secure_images(attachments)
|
||||
def inline_secure_images(attachments, attachments_index)
|
||||
stripped_media = @fragment.css('[data-stripped-secure-media]')
|
||||
upload_shas = {}
|
||||
stripped_media.each do |div|
|
||||
@@ -269,10 +269,8 @@ module Email
|
||||
upload = uploads.find { |upl| upl.sha1 == upload_shas[div['data-stripped-secure-media']] }
|
||||
next if !upload
|
||||
|
||||
original_filename = upload.original_filename
|
||||
|
||||
if attachments[original_filename]
|
||||
url = attachments[original_filename].url
|
||||
if attachments[attachments_index[upload.sha1]]
|
||||
url = attachments[attachments_index[upload.sha1]].url
|
||||
|
||||
onebox_type = div['data-onebox-type']
|
||||
style = if onebox_type
|
||||
|
||||
Reference in New Issue
Block a user