From e6da9c3d6ea5d9442c2effadfe144a8c30932744 Mon Sep 17 00:00:00 2001 From: "dmose%netscape.com" Date: Mon, 8 Jul 2002 23:58:42 +0000 Subject: [PATCH] Fix message filter matching failures on Message-ID and Content-Type: charset (bug 152468); r=naving@netscape.com, sr=bienvenu@netscape.com git-svn-id: svn://10.0.0.236/trunk@124777 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/local/src/nsParseMailbox.cpp | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/mozilla/mailnews/local/src/nsParseMailbox.cpp b/mozilla/mailnews/local/src/nsParseMailbox.cpp index 6c5323e3e6a..0d8c554b32f 100644 --- a/mozilla/mailnews/local/src/nsParseMailbox.cpp +++ b/mozilla/mailnews/local/src/nsParseMailbox.cpp @@ -1247,8 +1247,10 @@ int nsParseMailMessageState::FinalizeHeaders() ch = PL_strchr(recipient->value, ','); if (ch) { - *ch = 0; - recipient->length = strlen(recipient->value); + /* generate a new string that terminates before the , */ + nsCAutoString firstGroup; + firstGroup.Assign(recipient->value, ch - recipient->value); + m_newMsgHdr->SetRecipients(firstGroup.get()); } m_newMsgHdr->SetRecipients(recipient->value); } @@ -1317,11 +1319,16 @@ int nsParseMailMessageState::FinalizeHeaders() /* Take off <> around message ID. */ if (id->value[0] == '<') id->value++, id->length--; - if (id->value[id->length-1] == '>') - ((char *) id->value) [id->length-1] = 0, id->length--; /* #### const */ - - m_newMsgHdr->SetMessageId(id->value); - + + if (id->value[id->length-1] == '>') { + /* generate a new null-terminated string without the final > */ + nsCAutoString rawMsgId; + rawMsgId.Assign(id->value, id->length - 1); + m_newMsgHdr->SetMessageId(rawMsgId.get()); + } else { + m_newMsgHdr->SetMessageId(id->value); + } + if (!mozstatus && statush) { /* Parse a little bit of the Berkeley Mail status header. */ @@ -1378,8 +1385,15 @@ int nsParseMailMessageState::FinalizeHeaders() end++; if (*charset) { - *end = '\0'; - m_newMsgHdr->SetCharset(charset); + if (*end != '\0') { + // if we're not at the very end of the line, we need + // to generate a new string without the trailing crud + nsCAutoString rawCharSet; + rawCharSet.Assign(charset, end - charset); + m_newMsgHdr->SetCharset(rawCharSet.get()); + } else { + m_newMsgHdr->SetCharset(charset); + } } } }