receiving CDATA raises exception

Added by Peter Halacsy 691 days ago

if i send

sendMessage("ANY", new XML("<![CDATA[" + s + "]]>"));

raises exception at the other side

TypeError: Error #1085: The element type "A" must be terminated by the matching end-tag "</A>".
    at net.user1.reactor::XMLSocketConnection/dataListener()[/Users/colin/build/working/src/net/user1/reactor/XMLSocketConnection.as:220]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::XMLSocket/scanAndSendEvent()

Replies

RE: receiving CDATA raises exception - Added by colin moock 691 days ago

hi peter,
we have done a ton of work in the upcoming alpha 7 release to clean up character handling in all client/server communication. we believe we now correctly handle all transmissions; for example, in alpha 7 you can now create a room with the roomID "my <cool> room" (though obviously that's not the greatest choice of identifiers).

however, one rule we enforce universally starting with alpha 7 is: no CDATA in any message sent to the server. in our 1.0 release, if reactor encounters a "<" in a message, it adds an outer CDATA tag to that message. so if you do this:

room.sendMessage("TEST", true, null, "did you know 10 < 5?");

reactor actually sends this to union (notice the CDATA):

<U><M>u1</M><L><A>TEST</A><A>someRoom</A><A>true</A><A></A><A><![CDATA[did you know 10 < 5?]]></A></L></U>

XML does not allow nested CDATA, so adding CDATA in a message will cause errors.

post 1.0, we expect to move away from XML for our data transmission, so eventually you will be able to use CDATA as much as you like.

but for now, we intend to shipping 1.0 with XML-based data transmissions, so you have a few options:

1) knowing that CDATA is added automatically, you can just leave the CDATA out of your content
2) you can escape your CDATA's start tag (e.g., &lt![CDATA[...]]>)
3) if (1) and (2) don't work for you, you can tell us more about your situation, and we can consider adding options to address it

if you'd like to try testing your application with an alpha 7 prerelease, please let me know.

colin