Bug 1404049 - fix that mail.imap.use_literal_plus set to false may have no effect. r=jorgk
authorGene Smith <gds@chartertn.net>
Thu, 28 Sep 2017 23:35:21 -0400
changeset 29091 ac845a2682a78db055a3cf0323284a0f2e9e4b6f
parent 29090 86741416b36b16bb5aa2c68acef61430f45b7425
child 29092 45daaa0598d82fa06f66cd7e297bb1353153263d
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1404049
Bug 1404049 - fix that mail.imap.use_literal_plus set to false may have no effect. r=jorgk This is because it was only used in response to a CAPABILITY imap request. However, often CAPABILITY response occurs without a request so TB sees no need to do a request. Fix by moving the usage of use_literal_plus to where LITERAL+ capability is actually used.
mailnews/imap/src/nsImapProtocol.cpp
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -5462,24 +5462,16 @@ void nsImapProtocol::Capability()
     IncrementCommandTagNumber();
     nsCString command(GetServerCommandTag());
 
     command.AppendLiteral(" capability" CRLF);
 
     nsresult rv = SendData(command.get());
     if (NS_SUCCEEDED(rv))
         ParseIMAPandCheckForNewMail();
-    if (!gUseLiteralPlus)
-    {
-      eIMAPCapabilityFlags capabilityFlag = GetServerStateParser().GetCapabilityFlag();
-      if (capabilityFlag & kLiteralPlusCapability)
-      {
-        GetServerStateParser().SetCapabilityFlag(capabilityFlag & ~kLiteralPlusCapability);
-      }
-    }
 }
 
 void nsImapProtocol::ID()
 {
   if (!gAppName[0])
     return;
   IncrementCommandTagNumber();
   nsCString command(GetServerCommandTag());
@@ -6097,18 +6089,16 @@ void nsImapProtocol::UploadMessageFromFi
   uint32_t readCount;
   char *dataBuffer = nullptr;
   nsCString command(GetServerCommandTag());
   nsCString escapedName;
   CreateEscapedMailboxName(mailboxName, escapedName);
   nsresult rv;
   bool eof = false;
   nsCString flagString;
-  bool hasLiteralPlus = (GetServerStateParser().GetCapabilityFlag() &
-    kLiteralPlusCapability);
 
   nsCOMPtr <nsIInputStream> fileInputStream;
 
   if (!escapedName.IsEmpty())
   {
     command.AppendLiteral(" append \"");
     command.Append(escapedName);
     command.Append('"');
@@ -6161,25 +6151,31 @@ void nsImapProtocol::UploadMessageFromFi
     dataBuffer = (char*) PR_CALLOC(COPY_BUFFER_SIZE+1);
     if (!dataBuffer) goto done;
     rv = file->GetFileSize(&fileSize);
     NS_ASSERTION(fileSize, "got empty file in UploadMessageFromFile");
     if (NS_FAILED(rv) || !fileSize) goto done;
     rv = NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream), file);
     if (NS_FAILED(rv) || !fileInputStream) goto done;
     command.AppendInt((int32_t)fileSize);
-    if (hasLiteralPlus)
+
+    // Set useLiteralPlus to true if server has capability LITERAL+ and
+    // LITERAL+ useage is enabled in the config editor,
+    // i.e., "mail.imap.use_literal_plus" = true.
+    bool useLiteralPlus = (GetServerStateParser().GetCapabilityFlag() &
+                          kLiteralPlusCapability) && gUseLiteralPlus;
+    if (useLiteralPlus)
       command.AppendLiteral("+}" CRLF);
     else
       command.AppendLiteral("}" CRLF);
 
     rv = SendData(command.get());
     if (NS_FAILED(rv)) goto done;
 
-    if (!hasLiteralPlus)
+    if (!useLiteralPlus)
       ParseIMAPandCheckForNewMail();
 
     totalSize = fileSize;
     readCount = 0;
     while(NS_SUCCEEDED(rv) && !eof && totalSize > 0)
     {
       rv = fileInputStream->Read(dataBuffer, COPY_BUFFER_SIZE, &readCount);
       if (NS_SUCCEEDED(rv) && !readCount)