From 2732b1a0b51cb6ee3e9e831d59ad933dc70ccf2b Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 11 Nov 2019 01:35:01 -0500 Subject: Bug 1558595 Tag #1273 --- mailnews/mime/src/mimecms.cpp | 50 +++++++++++++++++++++++++++--------------- mailnews/mime/src/mimemcms.cpp | 19 +++++++++------- 2 files changed, 43 insertions(+), 26 deletions(-) (limited to 'mailnews/mime') diff --git a/mailnews/mime/src/mimecms.cpp b/mailnews/mime/src/mimecms.cpp index a3a3c47392..9289c0c33d 100644 --- a/mailnews/mime/src/mimecms.cpp +++ b/mailnews/mime/src/mimecms.cpp @@ -73,6 +73,7 @@ typedef struct MimeCMSdata bool parent_is_encrypted_p; bool parent_holds_stamp_p; nsCOMPtr smimeHeaderSink; + nsCString url; MimeCMSdata() :output_fn(nullptr), @@ -214,7 +215,9 @@ public: nsSMimeVerificationListener(const char *aFromAddr, const char *aFromName, const char *aSenderAddr, const char *aSenderName, - nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel); + nsIMsgSMIMEHeaderSink *aHeaderSink, + int32_t aMimeNestingLevel, + const nsCString &aMsgNeckoURL); protected: virtual ~nsSMimeVerificationListener() {} @@ -234,6 +237,7 @@ protected: bool mSinkIsNull; nsMainThreadPtrHandle mHeaderSink; int32_t mMimeNestingLevel; + nsCString mMsgNeckoURL; nsCString mFromAddr; nsCString mFromName; @@ -245,37 +249,43 @@ class SignedStatusRunnable : public mozilla::Runnable { public: SignedStatusRunnable(const nsMainThreadPtrHandle &aSink, int32_t aNestingLevel, - int32_t aSignatureStatus, nsIX509Cert *aSignerCert); + int32_t aSignatureStatus, nsIX509Cert *aSignerCert, + const nsCString &aMsgNeckoURL); NS_DECL_NSIRUNNABLE protected: nsMainThreadPtrHandle m_sink; int32_t m_nestingLevel; int32_t m_signatureStatus; nsCOMPtr m_signerCert; + nsCString m_msgNeckoURL; }; SignedStatusRunnable::SignedStatusRunnable(const nsMainThreadPtrHandle &aSink, int32_t aNestingLevel, int32_t aSignatureStatus, - nsIX509Cert *aSignerCert) : + nsIX509Cert *aSignerCert, + const nsCString &aMsgNeckoURL) : m_sink(aSink), m_nestingLevel(aNestingLevel), - m_signatureStatus(aSignatureStatus), m_signerCert(aSignerCert) + m_signatureStatus(aSignatureStatus), m_signerCert(aSignerCert), + m_msgNeckoURL(aMsgNeckoURL) { } NS_IMETHODIMP SignedStatusRunnable::Run() { - return m_sink->SignedStatus(m_nestingLevel, m_signatureStatus, m_signerCert); + return m_sink->SignedStatus(m_nestingLevel, m_signatureStatus, m_signerCert, + m_msgNeckoURL); } nsresult ProxySignedStatus(const nsMainThreadPtrHandle &aSink, int32_t aNestingLevel, int32_t aSignatureStatus, - nsIX509Cert *aSignerCert) + nsIX509Cert *aSignerCert, + const nsCString &aMsgNeckoURL) { RefPtr signedStatus = - new SignedStatusRunnable(aSink, aNestingLevel, aSignatureStatus, aSignerCert); + new SignedStatusRunnable(aSink, aNestingLevel, aSignatureStatus, aSignerCert, aMsgNeckoURL); return NS_DispatchToMainThread(signedStatus, NS_DISPATCH_SYNC); } @@ -283,7 +293,9 @@ NS_IMPL_ISUPPORTS(nsSMimeVerificationListener, nsISMimeVerificationListener) nsSMimeVerificationListener::nsSMimeVerificationListener(const char *aFromAddr, const char *aFromName, const char *aSenderAddr, const char *aSenderName, - nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel) + nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel, + const nsCString &aMsgNeckoURL) + : mMsgNeckoURL(aMsgNeckoURL) { mHeaderSink = new nsMainThreadPtrHolder(aHeaderSink); mSinkIsNull = !aHeaderSink; @@ -337,7 +349,8 @@ NS_IMETHODIMP nsSMimeVerificationListener::Notify(nsICMSMessage2 *aVerifiedMessa signature_status = nsICMSMessageErrors::SUCCESS; } - ProxySignedStatus(mHeaderSink, mMimeNestingLevel, signature_status, signerCert); + ProxySignedStatus(mHeaderSink, mMimeNestingLevel, signature_status, + signerCert, mMsgNeckoURL); return NS_OK; } @@ -473,8 +486,7 @@ static void *MimeCMS_init(MimeObject *obj, channel->GetURI(getter_AddRefs(uri)); if (uri) { - nsAutoCString urlSpec; - rv = uri->GetSpec(urlSpec); + rv = uri->GetSpec(data->url); // We only want to update the UI if the current mime transaction // is intended for display. @@ -488,10 +500,10 @@ static void *MimeCMS_init(MimeObject *obj, // If we do not find header=filter, we assume the result of the // processing will be shown in the UI. - if (!strstr(urlSpec.get(), "?header=filter") && - !strstr(urlSpec.get(), "&header=filter") && - !strstr(urlSpec.get(), "?header=attach") && - !strstr(urlSpec.get(), "&header=attach")) + if (!strstr(data->url.get(), "?header=filter") && + !strstr(data->url.get(), "&header=filter") && + !strstr(data->url.get(), "?header=attach") && + !strstr(data->url.get(), "&header=attach")) { msgurl = do_QueryInterface(uri); if (msgurl) @@ -567,6 +579,7 @@ void MimeCMSRequestAsyncSignatureVerification(nsICMSMessage *aCMSMsg, const char *aFromAddr, const char *aFromName, const char *aSenderAddr, const char *aSenderName, nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel, + const nsCString &aMsgNeckoURL, unsigned char* item_data, uint32_t item_len, int16_t digest_type) { @@ -576,7 +589,7 @@ void MimeCMSRequestAsyncSignatureVerification(nsICMSMessage *aCMSMsg, RefPtr listener = new nsSMimeVerificationListener(aFromAddr, aFromName, aSenderAddr, aSenderName, - aHeaderSink, aMimeNestingLevel); + aHeaderSink, aMimeNestingLevel, aMsgNeckoURL); if (!listener) return; @@ -684,7 +697,7 @@ MimeCMS_eof (void *crypto_closure, bool abort_p) from_addr.get(), from_name.get(), sender_addr.get(), sender_name.get(), data->smimeHeaderSink, aRelativeNestLevel, - nullptr, 0, 0); + data->url, nullptr, 0, 0); } } @@ -693,7 +706,8 @@ MimeCMS_eof (void *crypto_closure, bool abort_p) data->smimeHeaderSink->EncryptionStatus( aRelativeNestLevel, status, - certOfInterest + certOfInterest, + data->url ); } diff --git a/mailnews/mime/src/mimemcms.cpp b/mailnews/mime/src/mimemcms.cpp index b8b6a86692..1a281b1620 100644 --- a/mailnews/mime/src/mimemcms.cpp +++ b/mailnews/mime/src/mimemcms.cpp @@ -83,6 +83,7 @@ typedef struct MimeMultCMSdata bool parent_is_encrypted_p; bool parent_holds_stamp_p; nsCOMPtr smimeHeaderSink; + nsCString url; MimeMultCMSdata() :hash_type(0), @@ -125,6 +126,7 @@ extern void MimeCMSRequestAsyncSignatureVerification(nsICMSMessage *aCMSMsg, const char *aFromAddr, const char *aFromName, const char *aSenderAddr, const char *aSenderName, nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel, + const nsCString &aMsgNeckoURL, unsigned char* item_data, uint32_t item_len, int16_t digest_type); extern char *MimeCMS_MakeSAURL(MimeObject *obj); @@ -231,8 +233,7 @@ MimeMultCMS_init (MimeObject *obj) channel->GetURI(getter_AddRefs(uri)); if (uri) { - nsAutoCString urlSpec; - rv = uri->GetSpec(urlSpec); + rv = uri->GetSpec(data->url); // We only want to update the UI if the current mime transaction // is intended for display. @@ -246,10 +247,10 @@ MimeMultCMS_init (MimeObject *obj) // If we do not find header=filter, we assume the result of the // processing will be shown in the UI. - if (!strstr(urlSpec.get(), "?header=filter") && - !strstr(urlSpec.get(), "&header=filter")&& - !strstr(urlSpec.get(), "?header=attach") && - !strstr(urlSpec.get(), "&header=attach")) + if (!strstr(data->url.get(), "?header=filter") && + !strstr(data->url.get(), "&header=filter") && + !strstr(data->url.get(), "?header=attach") && + !strstr(data->url.get(), "&header=attach")) { msgurl = do_QueryInterface(uri); if (msgurl) @@ -425,10 +426,11 @@ MimeMultCMS_generate (void *crypto_closure) // We were not given all parts of the message. // We are therefore unable to verify correctness of the signature. - if (data->smimeHeaderSink) + if (data->smimeHeaderSink) { data->smimeHeaderSink->SignedStatus(aRelativeNestLevel, nsICMSMessageErrors::VERIFY_NOT_YET_ATTEMPTED, - nullptr); + nullptr, data->url); + } return nullptr; } @@ -455,6 +457,7 @@ MimeMultCMS_generate (void *crypto_closure) from_addr.get(), from_name.get(), sender_addr.get(), sender_name.get(), data->smimeHeaderSink, aRelativeNestLevel, + data->url, data->item_data, data->item_len, data->hash_type); -- cgit v1.2.3