E4X: Invalid characters inserted when calling XML.setNamespace with integer values.

RESOLVED WONTFIX

Status

()

Core
JavaScript Engine
RESOLVED WONTFIX
8 years ago
6 years ago

People

(Reporter: melkor, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)

When setNamespace is passed a namespace without a prefix it tries to assign one. If the prefix already exists it tries to create one with a unique name by appending "-" and a number. The name it tries for the prefix is the last non-numeric path component in the URI of the namespace. The obvious question is: What should happen when the URI contains no non-numeric components?

I do not have the answer to that question but the current behavior produces invalid XML.


Reproducible: Always

Steps to Reproduce:
var xml = new XML("<w/>");
for(var i = 0; i < 10; i++)
    xml.setNamespace(i);
var str = xml.toXMLString();

Actual Results:  
str == "<w xmlns:aaaa=\"0\" xmlns:a-1\x00=\"1\" xmlns:a-2\x00=\"2\" xmlns:a-3\x00=\"3\" xmlns:a-4\x00=\"4\" xmlns:a-5\x00=\"5\" xmlns:a-6\x00=\"6\" xmlns:a-7\x00=\"7\" xmlns:a-8\x00=\"8\" xmlns:a-9\x00=\"9\" xmlns=\"9\"/>"

Expected Results:  
Shouldn't contain null characters.

The results are even more interesting when you call it 1000 times and suggest something like a misaligned memory copy (which might indicate something much worse). Which is why I set this as "Normal" and not "Minor", after all this bug is easily avoided.

var xml = new XML("<w/>");
for(var i = 0; i < 1000; i++)
    xml.setNamespace(i);

var str = xml.toXMLString();

P.S. Is there any way to iterate over the functions in the "function" namespace of an XML object? Something like [a for(a in xml.function::*)]?
E4X is going away.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.