document.createComment rejects "--" in violation of the specification

RESOLVED FIXED in mozilla16

Status

()

Core
DOM
--
minor
RESOLVED FIXED
10 years ago
5 years ago

People

(Reporter: Amnon Aaronsohn, Assigned: ayg)

Tracking

Trunk
mozilla16
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b3pre) Gecko/2008011304 Minefield/3.0b3pre
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b3pre) Gecko/2008011304 Minefield/3.0b3pre

When you give document.createComment a string which can't appear in a comment according to XML rules, the method throws an exception.
This is non-standard behavior. See DOM level 3 core:

"""
No lexical check is done on the content of a comment and it is therefore possible to have the character sequence "--" (double-hyphen) in the content, which is illegal in a comment per section 2.5 of [XML 1.0]. The presence of this character sequence must generate a fatal error during serialization. 
"""


Reproducible: Always

Steps to Reproduce:
1.Type document.createComment("--") in the JS console

Actual Results:  
An exception is thrown:

Error: uncaught exception: [Exception... "String contains an invalid character"  code: "5" nsresult: "0x80530005 (NS_ERROR_DOM_INVALID_CHARACTER_ERR)"  location: "javascript:%20document.createComment("--") Line: 1"]

Expected Results:  
A Comment node containing the string "--" should be created

Updated

10 years ago
Summary: [FF3] document.createComment validates input → document.createComment rejects "--" in violation of DOM 3 Core spec
Version: unspecified → Trunk

Updated

7 years ago
Severity: normal → minor
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Hardware: x86 → All
Summary: document.createComment rejects "--" in violation of DOM 3 Core spec → document.createComment rejects "--" in violation of the specification
Still present in Firefox 4.0 RC, and still a bug per the current DOM Core spec:

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createcomment

All other browsers tested (IE 9 RC, Chrome 11 dev, Opera 11) create the comment successfully.

Updated

6 years ago
Blocks: 352728

Comment 2

6 years ago
Yeah, we should probably undo the createComment change from bug 352728.

Comment 3

6 years ago
Same for CDATASection, I think.

Updated

5 years ago
Duplicate of this bug: 750337
Created attachment 633110 [details] [diff] [review]
Patch v1

This might well still cause test failures, but they should be simple to fix.  Try: https://tbpl.mozilla.org/?tree=Try&rev=3ea71ee9f5c5
Assignee: nobody → ayg
Status: NEW → ASSIGNED
Attachment #633110 - Flags: review?(bzbarsky)

Comment 6

5 years ago
Comment on attachment 633110 [details] [diff] [review]
Patch v1

r=me
Attachment #633110 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/bc241a81c6a5
Flags: in-testsuite+
Target Milestone: --- → mozilla16
should https://hg.mozilla.org/integration/mozilla-inbound/rev/bc241a81c6a5#l2.65 read "should" rather than "shouldn't"?
https://hg.mozilla.org/mozilla-central/rev/bc241a81c6a5
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
(In reply to Mike "Pomax" Kamermans from comment #8)
> should
> https://hg.mozilla.org/integration/mozilla-inbound/rev/bc241a81c6a5#l2.65
> read "should" rather than "shouldn't"?

Oops -- thanks!

https://hg.mozilla.org/integration/mozilla-inbound/rev/4795650d4153
https://hg.mozilla.org/mozilla-central/rev/4795650d4153
You need to log in before you can comment on or make changes to this bug.