Closed Bug 16703 Opened 25 years ago Closed 25 years ago

[DOGFOOD] [BLOCKER] Crashes/bad behavior when trying to use InsertAsQuotation() Calls

Categories

(Core :: DOM: Editor, defect, P3)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: rhp, Assigned: rhp)

Details

(Whiteboard: [PDT+])

Attachments

(1 file)

Mail/news is trying to use the InsertAsQuotation() calls when replying to a
message and quoting the contents of the original message. The behavior is
different for Plain text and HTML instances of the editor.

In both cases, the first thing we do is load the url about:blank. This allows
us to have an editor that is initialized to the point we can make these calls.

For plain text:

 - The plain text is inserted correctly, but when a character is typed into the
editor window, the contents that were inserted dissapear

For HTML:

 - The InsertAsQuotation() crashes with the "doc" being NULL at line 642 of
nsDocLoader.cpp. The stack trace looks as follows:

nsDocLoaderImpl::GetContentViewerContainer(nsDocLoaderImpl * const 0x017047d0,
unsigned int 1242456, nsIContentViewerContainer * * 0x0012e5e0) line 642 + 5
bytes
nsObserverBase::NotifyWebShell(nsObserverBase * const 0x01705b48, unsigned int
1242456, const char * 0x0478a7f0, nsCharsetSource kCharsetFromMetaTag, const
char * 0x0012ea88) line 50 + 20 bytes
nsMetaCharsetObserver::Notify(nsMetaCharsetObserver * const 0x01705b40,
unsigned int 1242456, unsigned int 5, const unsigned short * * 0x0012ee68,
const unsigned short * * 0x0012ef30) line 275 + 49 bytes
nsMetaCharsetObserver::Notify(nsMetaCharsetObserver * const 0x01705b40,
unsigned int 1242456, const unsigned short * 0x0012ede8, unsigned int 5, const
unsigned short * * 0x0012ee68, const unsigned short * * 0x0012ef30) line 155
nsObserverNotifier::operator()(void * 0x01705b40) line 281 + 47 bytes
nsDeque::FirstThat(nsDequeFunctor & {...}) line 344 + 14 bytes
CObserverService::Notify(nsHTMLTag eHTMLTag_meta, nsIParserNode & {...},
unsigned int 1242456, const char * 0x021e10b0, nsAutoString & {"ISO-8859-1"},
nsCharsetSource & kCharsetUninitialized) line 832
CNavDTD::WillHandleStartTag(CToken * 0x0254c070, nsHTMLTag eHTMLTag_meta,
nsCParserNode & {...}) line 1042 + 36 bytes
CNavDTD::HandleStartToken(CToken * 0x0254c070) line 1214 + 20 bytes
CNavDTD::HandleToken(CNavDTD * const 0x04780940, CToken * 0x0254c070, nsIParser
* 0x047820d0) line 655 + 12 bytes
CNavDTD::BuildModel(CNavDTD * const 0x04780940, nsIParser * 0x047820d0,
nsITokenizer * 0x04780310, nsITokenObserver * 0x00000000, nsIContentSink *
0x04783e60) line 459 + 20 bytes
nsParser::BuildModel() line 1038 + 34 bytes
nsParser::ResumeParse(nsIDTD * 0x00000000, int 0) line 949 + 11 bytes
nsParser::Parse(const nsString & {""}, void * 0x0012f558, const nsString &
{"text/html"}, int 0, int 1, eParseMode eParseMode_autodetect) line 829 + 15
bytes
nsParser::ParseFragment(const nsString & {"<br><br>Rich Pizzarro
wrote:<br><BLOCKQUOTE TYPE=CITE><html><META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=UTF-8""}, void * 0x00000000, nsITagStack & {...},
unsigned int 0, const nsString & {"text/html"}, eParseMode
eParseMode_autodetect) line 919 + 41 bytes
nsRange::CreateContextualFragment(nsRange * const 0x04782cf4, const nsString &
{"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE TYPE=CITE><html><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8""},
nsIDOMDocumentFragment * * 0x0012f864) line 1841 + 52 bytes
nsHTMLEditor::InsertHTML(nsHTMLEditor * const 0x0478a1fc, const nsString &
{"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE TYPE=CITE><html><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8""}) line 1294 + 51
bytes
nsHTMLEditor::InsertAsCitedQuotation(nsHTMLEditor * const 0x0478a200, const
nsString & {"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE TYPE=CITE><html><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8""}, const nsString
& {""}) line 3279 + 20 bytes
nsHTMLEditorLog::InsertAsCitedQuotation(nsHTMLEditorLog * const 0x0478a200,
const nsString & {"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE
TYPE=CITE><html><META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=UTF-8""}, const nsString & {""}) line 453 + 17 bytes
nsHTMLEditor::InsertAsQuotation(nsHTMLEditor * const 0x0478a200, const nsString
& {"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE TYPE=CITE><html><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8""}) line 3218 + 23
bytes
nsHTMLEditorLog::InsertAsQuotation(nsHTMLEditorLog * const 0x0478a200, const
nsString & {"<br><br>Rich Pizzarro wrote:<br><BLOCKQUOTE TYPE=CITE><html><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8""}) line 417 + 13
bytes
nsEditorShell::InsertAsQuotation(nsEditorShell * const 0x04725280, const
unsigned short * 0x03b45f00) line 1870 + 42 bytes
QuotingOutputStreamListener::OnStopRequest(QuotingOutputStreamListener * const
0x04790100, nsIChannel * 0x047926c0, nsIChannel * 0x047926c0, unsigned int 0,
nsIChannel * 0x047926c0) line 876
nsStreamConverter::OnStopRequest(nsStreamConverter * const 0x04792760,
nsIChannel * 0x047938c4, nsISupports * 0x04793f90, unsigned int 0, const
unsigned short * 0x00000000) line 711
nsMsgProtocol::OnStopRequest(nsMsgProtocol * const 0x047938c0, nsIChannel *
0x04793d50, nsISupports * 0x04793f90, unsigned int 0, const unsigned short *
0x00000000) line 192 + 74 bytes
nsMailboxProtocol::OnStopRequest(nsMailboxProtocol * const 0x047938c0,
nsIChannel * 0x04793d50, nsISupports * 0x04793f90, unsigned int 0, const
unsigned short * 0x00000000) line 174
nsFileChannel::OnStopRequest(nsFileChannel * const 0x04793d54, nsIChannel *
0x04795150, nsISupports * 0x04793f90, unsigned int 0, const unsigned short *
0x00000000) line 414 + 45 bytes
nsOnStopRequestEvent::HandleEvent(nsOnStopRequestEvent * const 0x04796700) line
322
nsStreamListenerEvent::HandlePLEvent(PLEvent * 0x04797d00) line 169 + 12 bytes
PL_HandleEvent(PLEvent * 0x04797d00) line 534 + 10 bytes
PL_ProcessPendingEvents(PLEventQueue * 0x00ccd520) line 493 + 9 bytes
_md_EventReceiverProc(HWND__ * 0x017a0554, unsigned int 49365, unsigned int 0,
long 13423904) line 963 + 9 bytes
USER32! 77e71268()
Status: NEW → ASSIGNED
Target Milestone: M11
I see a similar crash on Linux when inserting into the plaintext editor.  I
suspect that there may be a problem due to there being no body tag.  I'm looking
into it.
Summary: Crashes/bad behavior when trying to use InsertAsQuotation() Calls → [BLOCKER] Crashes/bad behavior when trying to use InsertAsQuotation() Calls
Summary: [BLOCKER] Crashes/bad behavior when trying to use InsertAsQuotation() Calls → [DOGFOOD] [BLOCKER] Crashes/bad behavior when trying to use InsertAsQuotation() Calls
Vidur and Rick, can you help look at this?  This is a crash in the parser called
via nsRange::CreateContextualFragment when trying to parse a meta tag inserted
during a mail/news reply.

Here's the content that's being inserted:
--
<br><br>Akkana Peck wrote:<br><BLOCKQUOTE TYPE=CITE><html><PRE WRAP><META
HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
[Random text from the reply here]

</PRE></html></BLOCKQUOTE>
--
Seems like we've had problems before trying to insert html which contains an
html tag, but I don't remember what the conclusion was about whether this was
legal or not.  Rick?  Vidur?
The thing is that people are going to create HTML signatures with standard
tools (like Ender) and they will be self contained documents so this will be
the norm. Like I've mentioned before, I want to keep any sort of HTML parsing
out of libmime or the compose back end so I hope this type of content will be
allowed with the InsertAsQuotation() call.

- rhp
Blocks: 16907
Blocks: 16906
No longer blocks: 16906, 16907
The document into which I'm trying to insert looks like this:

body refcount=4<
  div moz_editor_bogus_node=TRUE refcount=11<
    blockquote type=cite refcount=5<
    >
    Text refcount=5<\u00a0>
  >
>

Rich, I agree with you about the body tag -- we should support that because
people will have signatures with those tags.  But this particular problem isn't
a signature problem -- the html and meta tags are coming from libmime and are in
the wrong place, so that seems like a bug in itself.  Where are they being set?
I'd like to try turning them off to see which one is causing the problem.

Rick thought the problem might be that there's a document observer watching for
meta tags, and that might be causing problems when inserting fragments.  I'd
like to be able to test this by trying it without the meta tag (I know that
inserting fragments with no meta and no html works, because my signature got
inserted correctly).
The HTML and META tags for charset's are being written in the libmime
emitter's. You can comment out the lines in the file:

     \mozilla\mailnews\mime\emitters\src\nsMimeHtmlEmitter.cpp

that ouput these tags. Around line 63 there are the following statements:

      UtilityWrite("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;
charset=");
      UtilityWrite(outCharset);
      UtilityWrite("\">");

Trying messing with these first.

- rhp
Thanks for the pointer!  Looks like it's actually the meta around line 304 of
that file, rather than the earlier one; but if I comment out both of them, then
the reply window comes up fine with the block-quoted text showing.

Rick, can we turn off the meta document observer when inserting fragments?
Rich, can we stop adding meta tags to fragments we're going to insert?  (Seems
like we shouldn't be adding the <html> tag either ... but at least Insert
Fragment is smart and knows enough to throw away the bogus html tag.)
Severity: normal → minor
The problem is that if we turn off META tag observation, I18N signatures and
I18N quoted material will start breaking all over the place.

- rhp
Assignee: akkana → rhp
Status: ASSIGNED → NEW
At this point it's pretty clear that there's not much the editor can do about
this, so I'm sending the bug back to Rich.  My suggestion is to stop adding the
meta tags to fragments you're about to insert.
Is the issue here the reload behavior because of meta tags...I can't turn that
off or I18N will have my head and all I18N Quoting will break. The problem is
that my "fragments" will be entire quoted messages.

Anyone .... HELP!

- rhp
Whiteboard: [PDT+]
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
We fixed this by removing the META tags from the quoted output and doing the
conversion in memory to UCS-2 before we send it to Ender.

- rhp
Blocks: 17432
Status: RESOLVED → VERIFIED
Yep. This works.
No longer blocks: 17432
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: