Bug #366839 --> remote images added by the user are not displayed when creating a reply or forward that is blocking remote content in the quoted text.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2007-02-08 17:43:18 +00:00
Родитель 15732e5525
Коммит e5501ba144
5 изменённых файлов: 61 добавлений и 10 удалений

Просмотреть файл

@ -77,6 +77,7 @@
#include "nsIWebNavigation.h"
#include "nsIDocShellTreeNode.h"
#include "nsContentPolicyUtils.h"
#include "nsIDOMHTMLImageElement.h"
static const char kBlockRemoteImages[] = "mailnews.message_display.disable_remote_image";
static const char kAllowPlugins[] = "mailnews.message_display.allow.plugins";
@ -336,7 +337,7 @@ nsMsgContentPolicy::ShouldLoad(PRUint32 aContentType,
NS_ENSURE_SUCCESS(rv, NS_OK);
if (windowType.Equals(NS_LITERAL_STRING("msgcompose")))
ComposeShouldLoad(rootDocShell, aContentLocation, aDecision);
ComposeShouldLoad(rootDocShell, aRequestingContext, aContentLocation, aDecision);
else
{
// the remote image could be nested in any number of iframes. For those cases, we don't really
@ -461,8 +462,8 @@ nsresult nsMsgContentPolicy::MailShouldLoad(nsIURI * aRequestingLocation, nsIURI
* Content policy logic for compose windows
*
*/
nsresult nsMsgContentPolicy::ComposeShouldLoad(nsIDocShell * aRootDocShell, nsIURI * aContentLocation,
PRInt16 * aDecision)
nsresult nsMsgContentPolicy::ComposeShouldLoad(nsIDocShell * aRootDocShell, nsISupports * aRequestingContext,
nsIURI * aContentLocation, PRInt16 * aDecision)
{
nsresult rv;
@ -489,7 +490,8 @@ nsresult nsMsgContentPolicy::ComposeShouldLoad(nsIDocShell * aRootDocShell, nsIU
// Only allow remote content for new mail compositions.
// Block remote content for all other types (drafts, templates, forwards, replies, etc)
// unless there is an associated msgHdr which allows the load...
// unless there is an associated msgHdr which allows the load, or unless the image is being
// added by the user and not the quoted message content...
if (composeType == nsIMsgCompType::New)
*aDecision = nsIContentPolicy::ACCEPT;
else if (!originalMsgURI.IsEmpty())
@ -498,6 +500,25 @@ nsresult nsMsgContentPolicy::ComposeShouldLoad(nsIDocShell * aRootDocShell, nsIU
rv = GetMsgDBHdrFromURI(originalMsgURI.get(), getter_AddRefs(msgHdr));
NS_ENSURE_SUCCESS(rv, NS_OK);
AllowRemoteContentForMsgHdr(msgHdr, nsnull, aContentLocation, aDecision);
// Special case image elements. When replying to a message, we want to allow the
// user to add remote images to the message. But we don't want remote images
// that are a part of the quoted content to load. Fortunately, after the quoted message
// has been inserted into the document, mail compose flags remote content elements that came
// from the original message with a moz-do-not-send attribute.
if (*aDecision == nsIContentPolicy::REJECT_REQUEST)
{
PRBool insertingQuotedContent = PR_TRUE;
msgCompose->GetInsertingQuotedContent(&insertingQuotedContent);
nsCOMPtr<nsIDOMHTMLImageElement> imageElement = do_QueryInterface(aRequestingContext);
if (!insertingQuotedContent && imageElement)
{
PRBool doNotSendAttrib;
if (NS_SUCCEEDED(imageElement->HasAttribute(NS_LITERAL_STRING("moz-do-not-send"), &doNotSendAttrib)) &&
!doNotSendAttrib)
*aDecision = nsIContentPolicy::ACCEPT;
}
}
}
return NS_OK;

Просмотреть файл

@ -85,7 +85,8 @@ protected:
nsresult AllowRemoteContentForSender(nsIMsgDBHdr * aMsgHdr, PRBool * aAllowForSender);
nsresult AllowRemoteContentForMsgHdr(nsIMsgDBHdr * aMsgHdr, nsIURI * aRequestingLocation, nsIURI * aContentLocation, PRInt16 *aDecision);
nsresult MailShouldLoad(nsIURI * aRequestingLocation, nsIURI * aContentLocation, PRInt16 * aDecision);
nsresult ComposeShouldLoad(nsIDocShell * aRootDocShell, nsIURI * aContentLocation, PRInt16 * aDecision);
nsresult ComposeShouldLoad(nsIDocShell * aRootDocShell, nsISupports *aRequestingContext,
nsIURI * aContentLocation, PRInt16 * aDecision);
nsresult GetRootDocShellForContext(nsISupports * aRequestingContext, nsIDocShell ** aDocShell);
nsresult GetMessagePaneURI(nsIDocShell * aRootDocShell, nsIURI ** aURI);

Просмотреть файл

@ -130,8 +130,7 @@ interface nsIMsgComposeRecyclingListener : nsISupports {
void onReopen(in nsIMsgComposeParams params);
};
[scriptable, uuid(bd6a81fc-e18e-413c-8086-1481b67447f4)]
[scriptable, uuid(41A7933D-DAC3-4a42-AA88-373A7DEA9F12)]
interface nsIMsgCompose : nsISupports {
/* ... */
@ -280,6 +279,11 @@ interface nsIMsgCompose : nsISupports {
readonly attribute string originalMsgURI;
attribute boolean deleteDraft;
/* true when the compose window is in the process of inserting quoted content
(i.e. via reply, forward inline or a quoting operation) into the document
*/
attribute boolean insertingQuotedContent;
};
/* send listener interface */

Просмотреть файл

@ -216,6 +216,7 @@ nsMsgCompose::nsMsgCompose()
#endif
mQuotingToFollow = PR_FALSE;
mInsertingQuotedContent = PR_FALSE;
mWhatHolder = 1;
m_window = nsnull;
m_editor = nsnull;
@ -434,6 +435,21 @@ nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditorMailSupport *aEditor)
return NS_OK;
}
NS_IMETHODIMP
nsMsgCompose::GetInsertingQuotedContent(PRBool * aInsertingQuotedText)
{
NS_ENSURE_ARG_POINTER(aInsertingQuotedText);
*aInsertingQuotedText = mInsertingQuotedContent;
return NS_OK;
}
NS_IMETHODIMP
nsMsgCompose::SetInsertingQuotedContent(PRBool aInsertingQuotedText)
{
mInsertingQuotedContent = aInsertingQuotedText;
return NS_OK;
}
NS_IMETHODIMP
nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
nsString& aBuf,
@ -480,8 +496,9 @@ nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
m_identity->GetReplyOnTop(&reply_on_top);
m_identity->GetSigBottom(&sig_bottom);
PRBool sigOnTop = (reply_on_top == 1 && !sig_bottom);
if ( (aQuoted) )
if (aQuoted)
{
mInsertingQuotedContent = PR_TRUE;
if (!aPrefix.IsEmpty())
{
if (!aHTMLEditor)
@ -504,6 +521,8 @@ nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
m_editor->EndOfDocument();
}
mInsertingQuotedContent = PR_FALSE;
(void)TagEmbeddedObjects(mailEditor);
if (!aSignature.IsEmpty() )
@ -525,7 +544,9 @@ nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
{
if (aHTMLEditor && htmlEditor)
{
mInsertingQuotedContent = PR_TRUE;
htmlEditor->RebuildDocumentFromSource(aBuf);
mInsertingQuotedContent = PR_FALSE;
m_editor->EndOfDocument();
@ -2604,8 +2625,10 @@ QuotingOutputStreamListener::InsertToCompose(nsIEditor *aEditor,
if (aEditor)
aEditor->EnableUndo(PR_TRUE);
if (!mMsgBody.IsEmpty())
nsCOMPtr<nsIMsgCompose> compose = do_QueryReferent(mWeakComposeObj);
if (!mMsgBody.IsEmpty() && compose)
{
compose->SetInsertingQuotedContent(PR_TRUE);
if (!mCitePrefix.IsEmpty())
{
if (!aHTMLEditor)
@ -2624,7 +2647,7 @@ QuotingOutputStreamListener::InsertToCompose(nsIEditor *aEditor,
else
mailEditor->InsertAsQuotation(mMsgBody, getter_AddRefs(nodeInserted));
}
compose->SetInsertingQuotedContent(PR_FALSE);
}
if (aEditor)

Просмотреть файл

@ -161,6 +161,8 @@ private:
nsCOMPtr<nsIMsgSendListener> mExternalSendListener;
nsCString mSmtpPassword;
PRBool mInsertingQuotedContent;
friend class QuotingOutputStreamListener;
friend class nsMsgComposeSendListener;
};