From a6144bb9e31df05ee499ba5cb3ce752e17d269e2 Mon Sep 17 00:00:00 2001 From: "akkana%netscape.com" Date: Thu, 17 Oct 2002 00:07:28 +0000 Subject: [PATCH] 173953: Fix plaintext quoting. r=ducarroz sr=bzbarsky --- editor/libeditor/html/nsHTMLDataTransfer.cpp | 7 ++++++ mailnews/compose/src/nsMsgCompose.cpp | 24 +++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index 07a80d27ba0d..84f0a29a615f 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -1810,6 +1810,13 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText, const nsAString & aCharset, nsIDOMNode **aNodeInserted) { + // Don't let anyone insert html into a "plaintext" editor: + if (mFlags & eEditorPlaintextMask) + { + NS_ASSERTION(!aInsertHTML, "InsertAsCitedQuotation: trying to insert html into plaintext editor"); + return InsertAsPlaintextQuotation(aQuotedText, PR_TRUE, aNodeInserted); + } + nsCOMPtr newNode; nsresult res = NS_OK; diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 105d36aa4eea..9362c8fd4aaf 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -534,7 +534,7 @@ nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix, nsCOMPtr mailEditor (do_QueryInterface(m_editor)); if (!aBuf.IsEmpty() && mailEditor) { - if (!mCiteReference.IsEmpty()) + if (aHTMLEditor && !mCiteReference.IsEmpty()) mailEditor->InsertAsCitedQuotation(aBuf, mCiteReference, PR_TRUE, @@ -2281,8 +2281,6 @@ QuotingOutputStreamListener::InsertToCompose(nsIEditor *aEditor, if (aEditor) aEditor->EnableUndo(PR_TRUE); - aEditor->BeginTransaction(); - if (!mMsgBody.IsEmpty()) { if (!mCitePrefix.IsEmpty()) @@ -2292,16 +2290,20 @@ QuotingOutputStreamListener::InsertToCompose(nsIEditor *aEditor, } nsCOMPtr mailEditor (do_QueryInterface(aEditor)); - nsAutoString empty; - mailEditor->InsertAsCitedQuotation(mMsgBody, - empty, - PR_TRUE, - NS_LITERAL_STRING("UTF-8"), - getter_AddRefs(nodeInserted)); + if (mailEditor) + { + if (aHTMLEditor) + mailEditor->InsertAsCitedQuotation(mMsgBody, + NS_LITERAL_STRING(""), + PR_TRUE, + NS_LITERAL_STRING("UTF-8"), + getter_AddRefs(nodeInserted)); + else + mailEditor->InsertAsQuotation(mMsgBody, getter_AddRefs(nodeInserted)); + } + } - aEditor->EndTransaction(); - if (aEditor) { nsCOMPtr textEditor = do_QueryInterface(aEditor);