From 44310620a7775d3a9b78cc8a4eecf266bdad19da Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Thu, 4 May 2000 22:16:25 +0000 Subject: [PATCH] Fix for bug 34467. We need to put back the double quote in some case. Let the parser do the right job. R=alecf --- mailnews/db/msgdb/public/nsMsgHdr.h | 1 + mailnews/db/msgdb/src/nsMsgHdr.cpp | 63 +++++++++++++++-------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/mailnews/db/msgdb/public/nsMsgHdr.h b/mailnews/db/msgdb/public/nsMsgHdr.h index e4139e4e82a4..a427a71959c9 100644 --- a/mailnews/db/msgdb/public/nsMsgHdr.h +++ b/mailnews/db/msgdb/public/nsMsgHdr.h @@ -55,6 +55,7 @@ protected: nsresult SetStringColumn(const char *str, mdb_token token); nsresult SetUInt32Column(PRUint32 value, mdb_token token); nsresult GetUInt32Column(mdb_token token, PRUint32 *pvalue, PRUint32 defaultValue = 0); + nsresult BuildRecipientsFromArray(const char *names, const char *addresses, PRUint32 numAddresses, nsCAutoString& allRecipients); // reference and threading stuff. nsresult ParseReferences(nsCString &references); diff --git a/mailnews/db/msgdb/src/nsMsgHdr.cpp b/mailnews/db/msgdb/src/nsMsgHdr.cpp index aa3da4175b64..8e08af9d8e9f 100644 --- a/mailnews/db/msgdb/src/nsMsgHdr.cpp +++ b/mailnews/db/msgdb/src/nsMsgHdr.cpp @@ -398,18 +398,31 @@ NS_IMETHODIMP nsMsgHdr::GetRecipientsIsNewsgroup(PRBool *rfc822) return NS_OK; } -NS_IMETHODIMP nsMsgHdr::SetRecipientsArray(const char *names, const char *addresses, PRUint32 numAddresses) +nsresult nsMsgHdr::BuildRecipientsFromArray(const char *names, const char *addresses, PRUint32 numAddresses, nsCAutoString& allRecipients) { nsresult ret; const char *curName = names; const char *curAddress = addresses; - nsCAutoString allRecipients; + nsIMsgHeaderParser *headerParser = m_mdb->GetHeaderParser(); - for (PRUint32 i = 0; i < numAddresses; i++) + for (PRUint32 i = 0; i < numAddresses; i++, curName += strlen(curName) + 1, curAddress += strlen(curAddress) + 1) { if (i > 0) allRecipients += ", "; + if (headerParser) + { + char * fullAddress; + ret = headerParser->MakeFullAddress(nsnull, curName, curAddress, &fullAddress); + if (NS_SUCCEEDED(ret) && fullAddress) + { + allRecipients += fullAddress; + nsCRT::free(fullAddress); + continue; + } + } + + // Just in case the parser failed... if (strlen(curName)) { allRecipients += curName; @@ -422,9 +435,20 @@ NS_IMETHODIMP nsMsgHdr::SetRecipientsArray(const char *names, const char *addres allRecipients += curAddress; allRecipients += '>'; } - curName += strlen(curName) + 1; - curAddress += strlen(curAddress) + 1; } + + return ret; +} + +NS_IMETHODIMP nsMsgHdr::SetRecipientsArray(const char *names, const char *addresses, PRUint32 numAddresses) +{ + nsresult ret; + nsCAutoString allRecipients; + + ret = BuildRecipientsFromArray(names, addresses, numAddresses, allRecipients); + if (NS_FAILED(ret)) + return ret; + ret = SetRecipients(allRecipients); SetRecipientsIsNewsgroup(PR_TRUE); return ret; @@ -439,33 +463,12 @@ NS_IMETHODIMP nsMsgHdr::SetCcList(const char *ccList) NS_IMETHODIMP nsMsgHdr::SetCCListArray(const char *names, const char *addresses, PRUint32 numAddresses) { nsresult ret; - const char *curName = names; - const char *curAddress = addresses; nsCAutoString allRecipients; + + ret = BuildRecipientsFromArray(names, addresses, numAddresses, allRecipients); + if (NS_FAILED(ret)) + return ret; - for (PRUint32 i = 0; i < numAddresses; i++) - { - if (i > 0) - allRecipients += ", "; - - if (strlen(curName)) - { - allRecipients += curName; - allRecipients += ' '; - } - - if (strlen(curAddress)) - { - if (strlen(curName)) - allRecipients += '<'; - else - allRecipients += "<"; - allRecipients += curAddress; - allRecipients += '>'; - } - curName += strlen(curName) + 1; - curAddress += strlen(curAddress) + 1; - } ret = SetCcList(allRecipients); return ret; }