Skip to content

Commit

Permalink
Merge pull request #649 from bcgov/test-marshal-NK-4339
Browse files Browse the repository at this point in the history
revert to old regex for side by side image and
  • Loading branch information
nkan-aot authored Dec 7, 2023
2 parents 56b14fa + 97f8228 commit 2f1be66
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public MSGFileProcessor(Stream sourceStream)
}
foreach (var inlineAttachment in inlineAttachments.OrderBy(m => m.GetType().GetProperty("RenderingPosition").GetValue(m, null)))
{
var startAt = 0;
if (rtfInline)
{
if (!inlineAttachment.GetType().FullName.ToLower().Contains("message"))
Expand Down Expand Up @@ -172,7 +173,10 @@ public MSGFileProcessor(Stream sourceStream)
else if (htmlInline)
{
var _inlineAttachment = (Storage.Attachment)inlineAttachment;
bodyreplaced = Regex.Replace(bodyreplaced, "src=\"cid:" + _inlineAttachment.ContentId, "style=\"max-width: 700px\" src=\"data:" + _inlineAttachment.MimeType + ";base64," + Convert.ToBase64String(_inlineAttachment.Data));
Regex regex = new Regex("<img((?!>).)*cid:" + _inlineAttachment.ContentId + ".*?>");
Match match = regex.Match(bodyreplaced, startAt);
bodyreplaced = regex.Replace(bodyreplaced, "<img style=\"max-width: 700px\" src=\"data:" + _inlineAttachment.MimeType + ";base64," + Convert.ToBase64String(_inlineAttachment.Data) + "\"/>", 1, startAt);
startAt = match.Index + match.Length;
foreach (KeyValuePair<MemoryStream, Dictionary<string, string>> attachment in attachmentsObj)
{
if (attachment.Value.ContainsKey("cid") && attachment.Value["cid"] == _inlineAttachment.ContentId)
Expand Down

0 comments on commit 2f1be66

Please sign in to comment.