fix 454344 nsIMimeEmitter::addAllHeaders not js safe, r=asuth, sr=neil
authorDavid Bienvenu <bienvenu@nventure.com>
Sun, 14 Sep 2008 08:23:21 -0700
changeset 327 98654f6296b5803008235fa5a696b81bde83ba04
parent 326 35d1c8c8e359d5c612e5b284b89a1a6b5aab6f71
child 328 80aa66c5e7d98a6f0b0a3cb034b6473aefca0553
push idunknown
push userunknown
push dateunknown
reviewersasuth, neil
bugs454344
fix 454344 nsIMimeEmitter::addAllHeaders not js safe, r=asuth, sr=neil
mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
mailnews/mime/public/nsIMimeEmitter.idl
mailnews/mime/src/mimemoz2.cpp
--- a/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
@@ -661,28 +661,27 @@ nsMimeBaseEmitter::AddHeaderField(const 
     ptr->value = strdup(value);
     tPtr->AppendElement(ptr);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMimeBaseEmitter::AddAllHeaders(const char *allheaders,
-                                 const PRInt32 allheadersize)
+nsMimeBaseEmitter::AddAllHeaders(const nsACString &allheaders)
 {
   if (mDocHeader) //We want to set only the main headers of a message, not the potentially embedded one
   {
     nsresult rv;
     nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(mURL));
     if (msgurl)
     {
         nsCOMPtr<nsIMimeHeaders> mimeHeaders = do_CreateInstance(NS_IMIMEHEADERS_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv,rv);
-        mimeHeaders->Initialize(allheaders, allheadersize);
+        mimeHeaders->Initialize(allheaders.BeginReading(), allheaders.Length());
         msgurl->SetMimeHeaders(mimeHeaders);
     }
   }
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // The following code is responsible for formatting headers in a manner that is
--- a/mailnews/mime/public/nsIMimeEmitter.idl
+++ b/mailnews/mime/public/nsIMimeEmitter.idl
@@ -51,17 +51,17 @@ interface nsMimeHeaderDisplayTypes
     const long AllHeaders = 2;
 };
 
 %{C++
 //#define NS_IMIME_MISC_STATUS_KEY       "@mozilla.org/messenger/mimestatus;1?"
 #define NS_IMIME_MISC_STATUS_KEY       "@mozilla.org/MimeMiscStatus;1?type="
 %}
 
-[scriptable, uuid(D01D7B59-DCCD-11d2-A411-00805F613C79)]
+[scriptable, uuid(8c9f218a-d1a6-4cb4-b985-e38140c0af93)]
 interface nsIMimeEmitter : nsISupports{
 
     // These will be called to start and stop the total operation
     void    Initialize(in nsIURI url, in nsIChannel aChannel, in long aFormat);
     void    Complete();
 
     // Set the output stream/listener for processed data.
     void    SetPipe(in nsIInputStream inputStream, in nsIOutputStream outStream);
@@ -69,17 +69,17 @@ interface nsIMimeEmitter : nsISupports{
 
     //Get the output listener to allow access to it from mime
     nsIStreamListener    GetOutputListener();
 
     // Header handling routines.
     void    StartHeader(in PRBool rootMailHeader, in PRBool headerOnly,
                         [const] in string msgID, [const] in string outCharset);
     void    AddHeaderField([const] in string field, [const] in string value);
-    void    addAllHeaders([const] in string allheaders, [const] in long allheadersize);
+    void    addAllHeaders(in ACString allheaders);
   void    WriteHTMLHeaders(); // book case this with a EndHeader call.
     void    EndHeader();
     void    UpdateCharacterSet([const] in string aCharset);
 
     // Attachment handling routines
     void    StartAttachment([const] in string name, [const] in string contentType,
                             [const] in string url, in PRBool aNotDownloaded);
     void    AddAttachmentField([const] in string field, [const] in string value);
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -1778,17 +1778,18 @@ mimeEmitterAddAllHeaders(MimeDisplayOpti
 
   mime_stream_data  *msd = GetMSD(opt);
   if (!msd)
     return NS_ERROR_FAILURE;
 
   if (msd->output_emitter)
   {
     nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
-    return emitter->AddAllHeaders(allheaders, allheadersize);
+    return emitter->AddAllHeaders(Substring(allheaders, 
+                                            allheaders + allheadersize));
   }
 
   return NS_ERROR_FAILURE;
 }
 
 extern "C" nsresult
 mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url,
                            PRBool aIsExternalAttachment)