mail-client-extensions
mail-client-extensions copied to clipboard
[FIX] Outlook: fix crash when adding inline images
Currently logging emails can crash if there are more inline image attachments than img tags.
Steps to reproduce
- Reply to an email that has an inline image
- From the reply, select "Log Email Into Contact"
- No log is created and the button is stuck in the loading state
Cause
Currently, we loop through inlineAttachments to match them one-to-one with the document's img tags. But the counter does not consider the case where there's a different number of inlineAttachments and imageElements. This usually happens when there's an img in the email history which is removed at the top of the function, but the attachment still exists. Some emails can also have embeded inline attachments that are unused.
Fix
Use two counters so that we don't hit an index out of bounds error. Also filter by img elements using cid: in src, so we don't overwrite img elements using URL images.
opw-4855422