Last Comment Bug 412257 - document.createComment rejects "--" in violation of the specification
: document.createComment rejects "--" in violation of the specification
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: All All
: -- minor (vote)
: mozilla16
Assigned To: Aryeh Gregor (:ayg) (away until October 25)
:
:
Mentors:
http://dvcs.w3.org/hg/domcore/raw-fil...
: 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:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch v1 (6.88 KB, patch)
2012-06-14 06:24 PDT, Aryeh Gregor (:ayg) (away until October 25)
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 (:ayg) (away until October 25) 2011-03-18 12:21:54 PDT
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.
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2011-03-18 12:37:11 PDT
Yeah, we should probably undo the createComment change from bug 352728.
Comment 3 Olli Pettay [:smaug] (reviewing overload) 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 (:ayg) (away until October 25) 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: https://tbpl.mozilla.org/?tree=Try&rev=3ea71ee9f5c5
Comment 6 Boris Zbarsky [:bz] (still a bit busy) 2012-06-14 07:20:07 PDT
Comment on attachment 633110 [details] [diff] [review]
Patch v1

r=me
Comment 7 Aryeh Gregor (:ayg) (away until October 25) 2012-06-15 05:14:20 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/bc241a81c6a5
Comment 8 Mike "Pomax" Kamermans [:pomax] 2012-06-15 07:37:36 PDT
should https://hg.mozilla.org/integration/mozilla-inbound/rev/bc241a81c6a5#l2.65 read "should" rather than "shouldn't"?
Comment 9 Ryan VanderMeulen [:RyanVM] 2012-06-16 06:52:56 PDT
https://hg.mozilla.org/mozilla-central/rev/bc241a81c6a5
Comment 10 Aryeh Gregor (:ayg) (away until October 25) 2012-06-17 02:36:51 PDT
(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
Comment 11 Ed Morley [:emorley] 2012-06-18 07:28:47 PDT
https://hg.mozilla.org/mozilla-central/rev/4795650d4153

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