Closed Bug 283972 Opened 19 years ago Closed 19 years ago

e4x: XML with namespaces doesn't allow to have two attributes with the same local name and the same namespace but Spidermonkey parses that without throwing an error

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: martin.honnen, Unassigned)

Details

Attachments

(1 file)

XML doesn't allow two attributes with the same name on one element, e.g.
  <god name="Kibo" name="Xibo" />
is not well-formed.
XML with namespaces restricts that further, it doesn't allow two attributes with
the same local name and the prefix bound to the same namespace URI, e.g.
  <god xmlns:pf1="http://example.com/2005/02/pf1"
xmlns:pf2="http://example.com/2005/02/pf1" pf1:name="Kibo" pf2:name="Xibo" />
is not well-formed.
Rhino catches that when parsing an XML literal, error message is:

line 1: uncaught JavaScript runtime exception: TypeError: error: Attribute
"name" bound to namespace "http://example.com/2005/02/pf1" was already specified
for element "god".

but Spidermonkey currently parses that stuff without throwing an error. As E4X
has namespace support I think it is better if E4X implements that restriction on
attribute names imposed by the XML with namespaces specification and throws an
error that the markup is not well-formed.

Test case:

var xml = <god xmlns:pf1="http://example.com/2005/02/pf1"
xmlns:pf2="http://example.com/2005/02/pf1" pf1:name="Kibo" pf2:name="Xibo" />;

if (typeof alert != 'undefined') {
  alert(xml.toXMLString());
}
else if (typeof print != 'undefined') {
  print(xml.toXMLString());
}

should throw a not well-formed error but doesn't.
Martin's testcase checked in as js/tests/e4x/Namespace/regress-283972.js
Is this a duplicate of bug 277664? In any case, it looks like that bug's checkin
fixed this as well. Marking as such.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Flags: testcase+
verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: