Server Side Parsing of XMPP: Part II

[ rakaur on Tue Nov 04 at 08:17 AM // category: programming, software, technology ]

I’ve learned a lot since part one, but nothing that helps anyone.

The XMPP RFC tells us we must be able to detect bad XML, and disconnect anyone that sends it. At the same time, we have to accept what could potentially be correct XML but an incomplete stanza (ie, a really big one that got split up). This is essentially impossible to do.

With Ruby’s REXML, I can meet it halfway by rejecting not-well-formed partial stanzas, but going ahead and waiting for the stanza to be completed (all tags closed). This allows me to accept partial stanzas as long as they’re able to be parsed.

With libxml, I can’t do anything. There’s no way to recover from on_parser_error(), so I can’t even get passed the opening <stream> (because it never closes).

With expat, which is the most popular XML parser, I can’t do this. I can either reject everything, or accept everything (as far as I can tell, the docs are nonexistent).

So right now my program tries to use expat and falls back to REXML on failure. That’s the best I can figure it out.

-- rakaur // 2008.11.04 @ 08:17 AM


0 TrackBacks

Listed below are links to blogs that reference this entry.

TrackBack URL for this entry: http://mt.ericw.org/mt-tb.cgi/330


Leave a comment


Name:
Email:
URL:   
Remember personal info?