Bug 1476788 - Reliably remove the "Re:" from an otherwise empty subject. r=jorgk DONTBUILD
authorAlfred Peters <infofrommozilla@gmail.com>
Sun, 16 Sep 2018 09:14:00 +0200
changeset 33166 c6d36dbf6916a586fb2482c9c31f97fbaae40e04
parent 33165 e385d269fb2511eb0c3299f72d07903c3c230e0c
child 33167 d197d42b67d83e5991554fa300ddeff7d1be5203
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1476788
Bug 1476788 - Reliably remove the "Re:" from an otherwise empty subject. r=jorgk DONTBUILD
mailnews/local/src/nsParseMailbox.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -1231,24 +1231,24 @@ nsresult nsParseMailMessageState::Intern
   /**
         We trust the X-Mozilla-Status line to be the smartest in almost
         all things.  One exception, however, is the HAS_RE flag.  Since
          we just parsed the subject header anyway, we expect that parsing
          to be smartest.  (After all, what if someone just went in and
         edited the subject line by hand?)
      */
   nsCString modifiedSubject;
-  if (NS_MsgStripRE(nsDependentCString(key), modifiedSubject))
+  bool strippedRE = NS_MsgStripRE(nsDependentCString(key), modifiedSubject);
+  if (strippedRE)
     flags |= nsMsgMessageFlags::HasRe;
   else
     flags &= ~nsMsgMessageFlags::HasRe;
   m_newMsgHdr->SetFlags(flags); // this *does not* update the mozilla-status header in the local folder
 
-  // Condense the subject text into as few MIME-2 encoded words as possible.
-  m_newMsgHdr->SetSubject(modifiedSubject.IsEmpty() ? key : modifiedSubject.get());
+  m_newMsgHdr->SetSubject(strippedRE ? modifiedSubject.get() : key);
 
   return NS_OK;
 }
 
 // we've reached the end of the envelope, and need to turn all our accumulated message_headers
 // into a single nsIMsgDBHdr to store in a database.
 nsresult nsParseMailMessageState::FinalizeHeaders()
 {
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -531,24 +531,25 @@ nsNNTPNewsgroupList::ParseLine(char *lin
   GET_TOKEN (); /* subject */
   if (line) {
     const char *subject = line;  /* #### const evilness */
 
     uint32_t flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
-    if (NS_MsgStripRE(nsDependentCString(subject), modifiedSubject))
+    bool strippedRE = NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
+    if (strippedRE)
       (void) newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
 
     // this will make sure read flags agree with newsrc
     if (! (flags & nsMsgMessageFlags::Read))
       rv = newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
-    rv = newMsgHdr->SetSubject(modifiedSubject.IsEmpty() ? subject : modifiedSubject.get());
+    rv = newMsgHdr->SetSubject(strippedRE ? modifiedSubject.get() : subject);
 
     if (NS_FAILED(rv))
       return rv;
   }
 
   GET_TOKEN (); /* author */
   if (line) {
     rv = newMsgHdr->SetAuthor(line);
@@ -1050,25 +1051,25 @@ nsNNTPNewsgroupList::AddHeader(const cha
   else if (PL_strcmp(header, "subject") == 0)
   {
     const char *subject = value;
 
     uint32_t flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
-    if (NS_MsgStripRE(nsDependentCString(subject), modifiedSubject))
+    bool strippedRE = NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
+    if (strippedRE)
       // this will make sure read flags agree with newsrc
      (void) m_newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
 
     if (! (flags & nsMsgMessageFlags::Read))
       rv = m_newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
-    rv = m_newMsgHdr->SetSubject(modifiedSubject.IsEmpty() ? subject :
-      modifiedSubject.get());
+    rv = m_newMsgHdr->SetSubject(strippedRE ? modifiedSubject.get() : subject);
   }
   else if (PL_strcmp(header, "message-id") == 0)
   {
     rv = m_newMsgHdr->SetMessageId(value);
   }
   else if (PL_strcmp(header, "references") == 0)
   {
     rv = m_newMsgHdr->SetReferences(value);