[FIX] Outlook: fix crash when adding inline images #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently logging emails can crash if there are more inline image attachments than img tags.
Steps to reproduce
Cause
Currently, we loop through
inlineAttachments
to match them one-to-one with the document'simg
tags. But the counter does not consider the case where there's a different number ofinlineAttachments
andimageElements
. 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 usingcid:
in src, so we don't overwriteimg
elements using URL images.opw-4855422