Bug 1440693 - avoid cloning the entire URL in some more cases. r=aceman
authorJorg K <jorgk@jorgk.com>
Tue, 06 Mar 2018 14:03:28 +0100
changeset 31233 894cbf4db50135cb80db34ec06b10b7e68429902
parent 31232 fa9449081261b554ae518d652b0948bf6b6d7d1c
child 31234 bda7b4ec2e7bc184d86283c94bdc63d04aa42f3b
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersaceman
bugs1440693
Bug 1440693 - avoid cloning the entire URL in some more cases. r=aceman
mailnews/compose/src/nsMsgComposeService.cpp
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -1328,17 +1328,22 @@ nsMsgComposeService::RunMessageThroughMi
   if (fileUrl || PromiseFlatCString(aMsgURI).Find("&type=application/x-message-display") >= 0)
     rv = NS_NewURI(getter_AddRefs(url), mailboxUri);
   else
     rv = messageService->GetUrlForUri(PromiseFlatCString(aMsgURI).get(), getter_AddRefs(url), aMsgWindow);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // ignore errors here - it's not fatal, and in the case of mailbox messages,
   // we're always passing in an invalid spec...
-  mozilla::Unused << NS_MutateURI(url).SetSpec(mailboxUri).Finalize(url);
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(url);
+  if (!mailnewsurl) {
+    NS_WARNING("Trying to run a message throught MIME which doesn't have a nsIMsgMailNewsUrl?");
+    return NS_ERROR_UNEXPECTED;
+  }
+  mozilla::Unused << mailnewsurl->SetSpecInternal(mailboxUri);
 
   // if we are forwarding a message and that message used a charset over ride
   // then use that over ride charset instead of the charset specified in the message
   nsCString mailCharset;
   if (aMsgWindow)
   {
     bool charsetOverride;
     if (NS_SUCCEEDED(aMsgWindow->GetCharsetOverride(&charsetOverride)) && charsetOverride)