Closed Bug 295531 Opened 19 years ago Closed 19 years ago

Crash in [@ nsHTMLEditor::InsertHTMLWithContext] inserting a space because it assumes that there is at least one node to paste

Categories

(Core :: DOM: Editor, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: mrbkap, Assigned: mrbkap)

References

Details

(Keywords: crash)

Crash Data

Attachments

(1 file, 1 obsolete file)

This function, which is called from ther Insert -> HTML dialog box in composer,
assumes in a couple of places that there is at least one node to paste. The
result is that if there isn't, it attempts to dereference nodeList[0], and
crashes for its efforts. I'm not entirely sure of why it makes this assumption,
but I have a patch that fixes it to not crash if there are no nodes to paste.

STEPS TO REPRODUCE:
1. Start composer
2. Click on Insert -> HTML
3. Enter ony a space
4. Click "Insert"

EXPECTED RESULTS: Nothing happens (or a space is inserted).
ACTUAL RESULTS: An assertion (followed by a crash).
This patch fixes the crash/assertion by bailing early if there is not, in fact,
anything to paste.

I'm not certain this is the right approach, but it seems to make sense in this
context.
Assignee: mozeditor → mrbkap
Status: NEW → ASSIGNED
Attachment #184545 - Flags: review?(brade)
Summary: nsHTMLEditor::InsertHTMLWithContext assumes that there is at least one node to paste → Crash in [@ nsHTMLEditor::InsertHTMLWithContext] because it assumes that there is at least one node to paste
Comment on attachment 184545 [details] [diff] [review]
bail early if there is nothing to paste

r=brade

I'm curious what data is causing there to be no nodes.	Is the editor being
asked to insert an empty string or ?
Attachment #184545 - Flags: review?(brade) → review+
Comment on attachment 184545 [details] [diff] [review]
bail early if there is nothing to paste

Editor is being asked to insert a space. I guess that at some point, spaces get
stripped out, leading to the crash.

Simon, can you sr?
Attachment #184545 - Flags: superreview?(sfraser_bugs)
what if i want to insert html &"&endash; :)
Comment on attachment 184545 [details] [diff] [review]
bail early if there is nothing to paste

After some more debugging, I no longer like this patch. The issue I was seeing
was _another_ htmlparser bug. I want to add an assertion though.
Attachment #184545 - Flags: superreview?(sfraser_bugs)
Attached patch add an assertionSplinter Review
It's worth adding an assertion, IMO, since we're making the assumption later,
anyway.
Attachment #184545 - Attachment is obsolete: true
Attachment #184631 - Flags: review?(brade)
Depends on: 295646
Summary: Crash in [@ nsHTMLEditor::InsertHTMLWithContext] because it assumes that there is at least one node to paste → Crash in [@ nsHTMLEditor::InsertHTMLWithContext] inserting a space because it assumes that there is at least one node to paste
Attachment #184631 - Flags: superreview+
Severity: critical → normal
Attachment #184631 - Flags: review?(brade) → review+
Comment on attachment 184631 [details] [diff] [review]
add an assertion

crasher fix
Attachment #184631 - Flags: approval1.8b3?
Comment on attachment 184631 [details] [diff] [review]
add an assertion

oh nevermind this actually adds an assertion only ;)
Attachment #184631 - Flags: approval1.8b3?
Comment on attachment 184631 [details] [diff] [review]
add an assertion

This assertion has already helped track down two dataloss problems in the HTML
parser, so it should probably go into 1.8b3
Attachment #184631 - Flags: approval1.8b3?
Comment on attachment 184631 [details] [diff] [review]
add an assertion

a=shaver
Attachment #184631 - Flags: approval1.8b3? → approval1.8b3+
Assertion checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Verified FIXED using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2)
Gecko/20050602 on Windows XP Seamonkey trunk using comment 0 as my testcase.

No crash, and inserting spaces (by themselves) does nothing, which is expected.
Status: RESOLVED → VERIFIED
Crash Signature: [@ nsHTMLEditor::InsertHTMLWithContext]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: