bug in e4x? missing = in XML attribute

Leni <[email protected]> Fri, 13 Feb 2009 10:16:14 +1100
Newsgroups gmane.comp.mozilla.devel.xml
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------040703020909070703000404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi, I think I may have encountered a bug in e4x parsing related to a 
3-byte sequence of UTF-8.

The reason I think it's a bug is that it seems unreasonable that the 
test case XML is parsable by the DOM parser but not the e4x parser.

Before filing in bugzilla I thought I would post here to see if anyone 
has another explanation for the behaviour.

An email describing the problem with a test case is attached.

Regards -

Leni.

--------------040703020909070703000404
Content-Type: message/rfc822;
 name="Attached Message"
Content-Disposition: inline;
 filename="Attached Message"
Content-Transfer-Encoding: 7bit

Message-ID: <[email protected]>
Date: Thu, 12 Feb 2009 11:32:56 +1100
From: Leni <[email protected]>
User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
MIME-Version: 1.0
To: [email protected]
Subject: e4x: missing = in XML attribute
Content-Type: multipart/mixed;
 boundary="------------070305050707040808020809"

This is a multi-part message in MIME format.
--------------070305050707040808020809
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi -

I am trying to parse the attached xml file as follows:

   var req = new XMLHttpRequest();
   req.open("GET", "chrome://myextension/content/1.xml", false);
   req.send(null);

   var xml = new XML(
             String(req.responseText).
               replace(/\<\?xml version=.*?\?\>/,""));

I'm seeing an error message in the javascript console:

   missing = in XML attribute

The problem relates to a sequence of three bytes in the <content> 
element between the "Kerry" and the "Ex".  od -x tells me the bit 
pattern is:
   0xe2 0x80 0xa8
which according to:
   http://en.wikipedia.org/wiki/UTF-8#Description
and
   http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char

is a valid 3-byte UTF-8 sequence.

According to this:
https://developer.mozilla.org/en/International_characters_in_XUL_JavaScript#How_the_character_encoding_is_determined_in_Gecko_1.8_and_later
the extension should be defaulting to UTF-8 and signalling that to the 
e4x processor.

So I'm not sure what this parsing error is about.

I've noticed through experimentation that changing some of the xml 
elsewhere (eg remove one of the redundant namespace delcarations) can 
change the error message or even make it go away entirely.

And if I avoid e4x and stick with DOM:

   var serializer = new XMLSerializer();
   var str = serializer.serializeToString(req.responseXML);
   alert(str);

it parses fine.

Any insight into what might be going on here would be welcome!

Leni.

--------------070305050707040808020809--


--------------040703020909070703000404
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
dev-tech-xml mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xml

--------------040703020909070703000404--