Closed Bug 466751 Opened 16 years ago Closed 16 years ago

setting .innerHTML to invalid markup in XHTML causes NS_ERROR_INVALID_POINTER

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: jqrusr.7.n1, Assigned: Gavin)

Details

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4

The error that occurs when one sets .innerHTML to something that is not valid XHTML is very cryptic and does not hint at all at the cause of the error, making it very hard to find the source of the problem.

Reproducible: Always

Steps to Reproduce:
1. create a document that is used in XHMTL standards mode
2. have it include a javascript function that sets invalid markup (e.g. foo.innerHTML = '<div ">';

Actual Results:  
uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: file://... :: <TOP_LEVEL> :: line 15"  data: no]

Line 0

Expected Results:  
A better error message or anything else that's more useful.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Attached patch patch (obsolete) — Splinter Review
The other caller of this method (nsRange::CreateContextualFragment) can already fail, so I think this should be OK.
Assignee: nobody → gavin.sharp
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #350094 - Flags: superreview?(jst)
Attachment #350094 - Flags: review?(jst)
That patch results in us throwing:
Error: uncaught exception: [Exception... "An invalid or illegal string was specified"  code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location: "https://bugzilla.mozilla.org/attachment.cgi?id=350091 Line: 15"]

Either way we show a "not well formed" error in addition to the innerHTML exception, as far as I can tell, so this isn't *too* big of a deal.
OS: Linux → All
Hardware: PC → All
Version: unspecified → Trunk
Attachment #350094 - Flags: superreview?(jst)
Attachment #350094 - Flags: superreview+
Attachment #350094 - Flags: review?(jst)
Attachment #350094 - Flags: review+
Attached patch with testSplinter Review
Attachment #350091 - Attachment is obsolete: true
Attachment #350094 - Attachment is obsolete: true
Flags: in-testsuite?
https://hg.mozilla.org/mozilla-central/rev/e81a52c40a43
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: in-testsuite? → in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Blocks: 474376
No longer blocks: 474376
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: