Skip to content

Commit

Permalink
Fix: Assume all mailbox addresses domains are absolute when comparing…
Browse files Browse the repository at this point in the history
… to generate BCC.
  • Loading branch information
rnwood committed Apr 24, 2024
1 parent 1e115fe commit 328ba34
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Rnwood.Smtp4dev/ApiModel/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public Message(DbModel.Message dbMessage)
foreach (var internetAddress in MimeMessage.To.Where(t => t is MailboxAddress))
{
var to = (MailboxAddress)internetAddress;
recipients.Remove(PunyCodeReplacer.DecodePunycode(to.Address));
var decodedToAddress = PunyCodeReplacer.DecodePunycode(to.Address);
recipients.Remove(decodedToAddress.TrimEnd('.'));
recipients.Remove($"{decodedToAddress}.");
}
}

Expand All @@ -66,7 +68,9 @@ public Message(DbModel.Message dbMessage)
foreach (var internetAddress in MimeMessage.Cc.Where(t => t is MailboxAddress))
{
var cc = (MailboxAddress)internetAddress;
recipients.Remove(PunyCodeReplacer.DecodePunycode(cc.Address));
var decodedCCAddress = PunyCodeReplacer.DecodePunycode(cc.Address);
recipients.Remove(decodedCCAddress.TrimEnd('.'));
recipients.Remove($"{decodedCCAddress}.");
}
}

Expand Down Expand Up @@ -145,7 +149,7 @@ internal static FileStreamResult GetPartContent(Message result, string cid)
{
var contentEntity = GetPart(result, cid);

if (contentEntity is MimePart mimePart)
if (contentEntity is MimePart mimePart && mimePart.Content != null)
{
return new FileStreamResult(mimePart.Content.Open(), contentEntity.ContentType?.MimeType ?? "application/text")
{
Expand All @@ -171,7 +175,7 @@ internal static string GetPartContentAsText(Message result, string id)
{
var contentEntity = GetPart(result, id);

if (contentEntity is MimePart part)
if (contentEntity is MimePart part && part.Content != null)
{
var encoding = part.ContentType.CharsetEncoding ?? ApiModel.Message.GetSessionEncodingOrAssumed(result);
using var reader = new StreamReader(part.Content.Open(), encoding);
Expand Down

0 comments on commit 328ba34

Please sign in to comment.