Bug 793118 - Do not send network shared file as normal attachment when already uploded to filelink. r=mkmelin,jorgk a=wsmwk THUNDERBIRD_68_11_0_BUILD1 THUNDERBIRD_68_11_0_RELEASE
authorPing Chen <remotenonsense@gmail.com>
Mon, 29 Jun 2020 11:00:04 +0900
changeset 36210 a247645d951bcedb356a0d9f273e878a7d4d2180
parent 36209 6e197ba62e2236087addfb4a0fe738899ce5f684
child 36211 a80ea2d1e817e2ab1ab20eac4d456dcac56256d4
push id114
push userthunderbird@calypsoblue.org
push dateTue, 21 Jul 2020 20:15:00 +0000
treeherdercomm-esr68@a247645d951b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk, wsmwk
bugs793118
Bug 793118 - Do not send network shared file as normal attachment when already uploded to filelink. r=mkmelin,jorgk a=wsmwk
mailnews/compose/src/nsMsgCompUtils.cpp
mailnews/compose/src/nsMsgCompUtils.h
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -1311,31 +1311,16 @@ nsresult nsMsgNewURL(nsIURI **aInstanceP
     nsAutoCString uri(NS_LITERAL_CSTRING("http://"));
     uri.Append(aSpec);
     rv = pNetService->NewURI(uri, nullptr, nullptr, aInstancePtrResult);
   } else
     rv = pNetService->NewURI(aSpec, nullptr, nullptr, aInstancePtrResult);
   return rv;
 }
 
-bool nsMsgIsLocalFile(const char *url) {
-  /*
-    A url is considered as a local file if it's start with file://
-    But on Window, we need to filter UNC file url because there
-    are not really local file. Those start with file:////
-  */
-  if (PL_strncasecmp(url, "file://", 7) == 0) {
-#ifdef XP_WIN
-    if (PL_strncasecmp(url, "file:////", 9) == 0) return false;
-#endif
-    return true;
-  } else
-    return false;
-}
-
 char *nsMsgGetLocalFileFromURL(const char *url) {
   char *finalPath;
   NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
   finalPath = (char *)PR_Malloc(strlen(url));
   if (finalPath == NULL) return NULL;
   strcpy(finalPath, url + 6 + 1);
   return finalPath;
 }
--- a/mailnews/compose/src/nsMsgCompUtils.h
+++ b/mailnews/compose/src/nsMsgCompUtils.h
@@ -102,17 +102,16 @@ void msg_pick_real_name(nsMsgAttachmentH
 //
 void nsMsgMIMESetConformToStandard(bool conform_p);
 bool nsMsgMIMEGetConformToStandard(void);
 
 //
 // network service type calls...
 //
 nsresult nsMsgNewURL(nsIURI **aInstancePtrResult, const nsCString &aSpec);
-bool nsMsgIsLocalFile(const char *url);
 char *nsMsgGetLocalFileFromURL(const char *url);
 
 char *nsMsgParseURLHost(const char *url);
 
 char *GenerateFileNameFromURI(nsIURI *aURL);
 
 //
 // Folder calls...
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1689,17 +1689,17 @@ nsresult nsMsgComposeAndSend::CountCompF
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
     if (NS_SUCCEEDED(rv) && attachment) {
       attachment->GetUrl(url);
       if (!url.IsEmpty()) {
         // Check to see if this is a file URL, if so, don't retrieve
         // like a remote URL...
-        if (nsMsgIsLocalFile(url.get()))
+        if (PL_strncasecmp(url.get(), "file://", 7) == 0)
           mCompFieldLocalAttachments++;
         else  // This is a remote URL...
           mCompFieldRemoteAttachments++;
       }
     }
   }
 
   return NS_OK;
@@ -1745,17 +1745,17 @@ nsresult nsMsgComposeAndSend::AddCompFie
           // m_attachments[newLoc]->m_done = true;
           attachment->GetHtmlAnnotation(m_attachments[newLoc]->mHtmlAnnotation);
           m_attachments[newLoc]->m_type.AssignLiteral("text/html");
           attachment->GetCloudFileAccountKey(
               m_attachments[newLoc]->mCloudFileAccountKey);
           attachment->GetContentLocation(m_attachments[newLoc]->mCloudUrl);
         }
         // Just look for local file:// attachments and do the right thing.
-        if (nsMsgIsLocalFile(url.get())) {
+        if (PL_strncasecmp(url.get(), "file://", 7) == 0) {
           //
           // Now we have to setup the m_attachments entry for the file://
           // URL that is passed in...
           //
           m_attachments[newLoc]->mDeleteFile = false;
 
           nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
 
@@ -1915,17 +1915,17 @@ nsresult nsMsgComposeAndSend::AddCompFie
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
     if (NS_SUCCEEDED(rv) && attachment) {
       attachment->GetUrl(url);
       if (!url.IsEmpty()) {
         // Just look for files that are NOT local file attachments and do
         // the right thing.
-        if (!nsMsgIsLocalFile(url.get())) {
+        if (PL_strncasecmp(url.get(), "file://", 7) != 0) {
           // Check for message attachment, see
           // nsMsgMailNewsUrl::GetIsMessageUri.
           nsCOMPtr<nsIURI> nsiuri;
           rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
                    .SetSpec(url)
                    .Finalize(nsiuri);
           NS_ENSURE_SUCCESS(rv, rv);