fix(email): generate random filename when attachment filenames are same upon inbound email (#18483)

Fix issue when an email has multiple inline images with the same filename. Currently the cid_map is overwritten; instead, attach the files with different names. Emails where every inline image has the filename 'image.png', only one of the images ends up correctly linked.
This commit is contained in:
Andrew McLeod 2022-10-23 20:07:49 +01:00 committed by GitHub
parent 8222a60546
commit 01fe2da368
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -604,6 +604,9 @@ class Email:
fname = get_random_filename(content_type=content_type)
else:
fname = get_random_filename(content_type=content_type)
# Don't clobber existing filename
while fname in self.cid_map:
fname = get_random_filename(content_type=content_type)
self.attachments.append(
{