Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert to old regex for side by side image and #649

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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