Last Comment Bug 412257 - document.createComment rejects "--" in violation of the specification
: document.createComment rejects "--" in violation of the specification
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: All All
: -- minor (vote)
: mozilla16
Assigned To: :Aryeh Gregor (working until September 2)
: 750337 (view as bug list)
Depends on:
Blocks: 352728
  Show dependency treegraph
Reported: 2008-01-14 04:21 PST by Amnon Aaronsohn
Modified: 2012-06-18 07:28 PDT (History)
4 users (show)
ayg: in‑testsuite+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch v1 (6.88 KB, patch)
2012-06-14 06:24 PDT, :Aryeh Gregor (working until September 2)
bzbarsky: review+
Details | Diff | Splinter Review

Description Amnon Aaronsohn 2008-01-14 04:21:56 PST
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
Comment 1 :Aryeh Gregor (working until September 2) 2011-03-18 12:21:54 PDT
Still present in Firefox 4.0 RC, and still a bug per the current DOM Core spec:

All other browsers tested (IE 9 RC, Chrome 11 dev, Opera 11) create the comment successfully.
Comment 2 Boris Zbarsky [:bz] 2011-03-18 12:37:11 PDT
Yeah, we should probably undo the createComment change from bug 352728.
Comment 3 Olli Pettay [:smaug] (vacation Aug 25-28) 2011-03-19 09:57:34 PDT
Same for CDATASection, I think.
Comment 4 John P Baker 2012-05-01 01:34:37 PDT
*** Bug 750337 has been marked as a duplicate of this bug. ***
Comment 5 :Aryeh Gregor (working until September 2) 2012-06-14 06:24:39 PDT
Created attachment 633110 [details] [diff] [review]
Patch v1

This might well still cause test failures, but they should be simple to fix.  Try:
Comment 6 Boris Zbarsky [:bz] 2012-06-14 07:20:07 PDT
Comment on attachment 633110 [details] [diff] [review]
Patch v1

Comment 7 :Aryeh Gregor (working until September 2) 2012-06-15 05:14:20 PDT
Comment 8 Mike "Pomax" Kamermans [:pomax] 2012-06-15 07:37:36 PDT
should read "should" rather than "shouldn't"?
Comment 9 Ryan VanderMeulen [:RyanVM] 2012-06-16 06:52:56 PDT
Comment 10 :Aryeh Gregor (working until September 2) 2012-06-17 02:36:51 PDT
(In reply to Mike "Pomax" Kamermans from comment #8)
> should
> read "should" rather than "shouldn't"?

Oops -- thanks!
Comment 11 Ed Morley [:emorley] 2012-06-18 07:28:47 PDT

Note You need to log in before you can comment on or make changes to this bug.