Bug 1271353 - check own email addresses case-insensitively in correspondents column and ignore plus addressing part. r=jorgk

This commit is contained in:
Magnus Melin 2018-11-21 10:40:25 +02:00
Родитель efacd58fa6
Коммит f4a60c026d
1 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -911,6 +911,24 @@ nsMsgDBView::FetchLabel(nsIMsgDBHdr *aHdr,
return NS_OK;
}
/**
* Lowercase the email and remove a possible plus addressing part.
* E.g. John+test@example.com -> john@example.com.
*/
static void
ToLowerCaseDropPlusAddessing(nsCString& aEmail)
{
ToLowerCase(aEmail);
int32_t indPlus;
if ((indPlus = aEmail.FindChar('+')) == kNotFound)
return;
int32_t indAt;
indAt = aEmail.FindChar('@', indPlus);
if (indAt == kNotFound)
return;
aEmail.ReplaceLiteral(indPlus, indAt - indPlus, "");
}
bool
nsMsgDBView::IsOutgoingMsg(nsIMsgDBHdr* aHdr)
{
@ -920,7 +938,7 @@ nsMsgDBView::IsOutgoingMsg(nsIMsgDBHdr* aHdr)
nsCString emailAddress;
nsString name;
ExtractFirstAddress(DecodedHeader(author), name, emailAddress);
ToLowerCaseDropPlusAddessing(emailAddress);
return mEmails.Contains(emailAddress);
}
@ -2548,12 +2566,16 @@ nsMsgDBView::Open(nsIMsgFolder *folder,
nsCString email;
identity->GetEmail(email);
if (!email.IsEmpty())
if (!email.IsEmpty()) {
ToLowerCaseDropPlusAddessing(email);
mEmails.PutEntry(email);
}
identity->GetReplyTo(email);
if (!email.IsEmpty())
if (!email.IsEmpty()) {
ToLowerCaseDropPlusAddessing(email);
mEmails.PutEntry(email);
}
}
return NS_OK;