don't include url for file links in attachment, don't show attachments, r=mconley, a=bienvenu. bug 748799
authorDavid Bienvenu <dbienvenu@mozilla.com>
Mon, 30 Apr 2012 13:01:08 -0400
changeset 11285 834a6df4263e4f86e92927905490d74ab22b59ce
parent 11284 028c8a8a8beb6b53a9812a5fd9bac3505203f5ac
child 11286 879174a2498545929e7e9d43c96a682010d0f984
push id473
push usermconley@mozilla.com
push dateMon, 30 Apr 2012 17:01:50 +0000
treeherdercomm-beta@834a6df4263e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, bienvenu
bugs748799
don't include url for file links in attachment, don't show attachments, r=mconley, a=bienvenu. bug 748799
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1134,17 +1134,17 @@ nsMsgComposeAndSend::PreProcessPart(nsMs
 
   nsCString type(ma->m_type);
   nsCString realName(ma->m_realName);
 
   // for cloud attachments, make the part an html part with no name,
   // so we don't show it as an attachment.
   if (ma->mSendViaCloud)
   {
-    type.Assign("text/html");
+    type.Assign("application/octet-stream");
     realName.Truncate();
   }
   hdrs = mime_generate_attachment_headers (type.get(),
                                            ma->m_typeParam.get(),
                                            ma->m_encoding.get(),
                                            ma->m_description.get(),
                                            ma->m_xMacType.get(),
                                            ma->m_xMacCreator.get(),
@@ -1164,41 +1164,36 @@ nsMsgComposeAndSend::PreProcessPart(nsMs
                                            false);
   if (!hdrs)
     return 0;
 
   status = part->SetOtherHeaders(hdrs);
   PR_FREEIF(hdrs);
   if (ma->mSendViaCloud)
   {
-    // put the url in an html part
-    nsCString htmlPart("<html><body><a href=\"");
-    htmlPart.Append(ma->mCloudUrl);
-    htmlPart.Append("\">");
-    htmlPart.Append(ma->mCloudUrl);
-    htmlPart.Append("</a></body></html>");
-    part->SetBuffer(htmlPart.get());
+    nsCString urlSpec;
+    ma->mURL->GetSpec(urlSpec);
+    // Need to add some headers so that libmime can restore the cloud info
+    // when loading a draft message.
+    nsCString draftInfo(HEADER_X_MOZILLA_CLOUD_PART": cloudFile; url=");
+    draftInfo.Append(ma->mCloudUrl.get());
+    // don't leak user file paths or account keys to recipients.
     if (m_deliver_mode == nsMsgSaveAsDraft)
     {
-      nsCString urlSpec;
-      ma->mURL->GetSpec(urlSpec);
-      // Need to add some headers so that libmime can restore the cloud info
-      // when loading a draft message.
-      nsCString draftInfo(HEADER_X_MOZILLA_CLOUD_PART": cloudFile; url=");
-      draftInfo.Append(ma->mCloudUrl.get());
       draftInfo.Append("; provider=");
       draftInfo.Append(ma->mCloudProviderKey.get());
       draftInfo.Append("; file=");
       draftInfo.Append(urlSpec.get());
-      draftInfo.Append("; name=");
-      draftInfo.Append(ma->m_realName.get());
-      draftInfo.Append(CRLF);
-      part->AppendOtherHeaders(draftInfo.get());
     }
-    part->SetType("text/html");
+    draftInfo.Append("; name=");
+    draftInfo.Append(ma->m_realName.get());
+    draftInfo.Append(CRLF);
+    part->AppendOtherHeaders(draftInfo.get());
+    part->SetType("application/octet-stream");
+    part->SetBuffer("");
   }
   if (NS_FAILED(status))
     return 0;
   status = part->SetFile(ma->mTmpFile);
   if (NS_FAILED(status))
     return 0;
   if (ma->m_encoder_data)
   {