Closed Bug 390816 Opened 18 years ago Closed 13 years ago

setAttribute with ; doesn't work, NS_ERROR_DOM_INVALID_CHARACTER_ERR error

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: martijn.martijn, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

Attached file testcase
See testcase, I get a js error with that testcase, because .setAttribute(';',';') isn't allowed. It works fine in IE and Opera. Actual result: <pre id="result" style="white-space: -moz-pre-wrap; width: 600px;">[Exception... "String contains an invalid character" code: "5" nsresult: "0x80530005 (NS_ERROR_DOM_INVALID_CHARACTER_ERR)" location: "file:///C:/Documents%20and%20Settings/mw/Bureaublad/attributes2.htm Line: 6"]</pre> Expected result: <pre id=result style="WIDTH: 600px" ;=";"></pre> What is even more string with Mozilla is that, if the element already has an attribute named ';', then it suddenly does work in Mozilla without errors.
I guess that attribute name is rejected by MOZ_XMLCheckQName, but it works if the attribute already exists because InternalGetExistingAttrNameFromQName finds it in that case and we don't rely on MOZ_XMLCheckQName to validate the name (via nsContentUtils::CheckQName).
OS: Windows XP → All
Hardware: PC → All
Sounds like MOZ_XMLCheckQName is buggy? Or perhaps we shouldn't use it in HTML?
Flags: blocking1.9?
MOZ_XMLCheckQName is fine, ";" isn't a valid character for an QName in XML. Note that DOM Level 3 Core only talks about checking for XML name validity (http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68F082). I'm fine with switching to HTML5 name checking in HTML documents instead (see http://www.whatwg.org/specs/web-apps/current-work/#attributes1). Don't think this should have a very high priority though :-).
not blocking since we're not even sure this is a bug. Feel free to renominate if we actually determine that we do want to make a change, and we can find sites out there that does depend on it. Likely this is only going to be [wanted-1.9] at the most though.
Flags: blocking1.9? → blocking1.9-
Summary: Settattribute with ; doesn't work, NS_ERROR_DOM_INVALID_CHARACTER_ERR error → setAttribute with ; or : doesn't work, NS_ERROR_DOM_INVALID_CHARACTER_ERR error
Don't think ';' and ':' are the same, one is a valid name start character and the other is not.
Summary: setAttribute with ; or : doesn't work, NS_ERROR_DOM_INVALID_CHARACTER_ERR error → setAttribute with ; doesn't work, NS_ERROR_DOM_INVALID_CHARACTER_ERR error
(In reply to comment #6) > Don't think ';' and ':' are the same, one is a valid name start character and > the other is not. OK. They're both rejected by MOZ_XMLCheckQName, though (for different reasons, http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/parser/expat/lib/moz_extensions.c&rev=1.11&mark=76,113#61 ).
AFAICT, Gecko/WebKit/Presto and the spec align here, while IE9 (in quirks mode, note) is too lenient.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
(Thanks to KWierso for checking IE)
Why not do the same as IE?
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Please send email to www-dom if you want this to change; I don't expect us to change this before the spec.
Status: REOPENED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → INVALID
I don't want the spec to change, I want Mozilla to change (perhaps).
If we believe the spec is wrong, we should be advocating to change it. If we don't believe the spec is wrong, we should not be behaving differently.
The spec should do what browsers are doing, not the other way around.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: