[jdev] parsing xml (xmpp) with ruby

Remko Tronçon remko at el-tramo.be
Wed Oct 1 14:00:16 CDT 2008


> If someone is manually sending XML, and never sends an end tag, it will
> keep on adding to the buffer forever. What should I do about this? Set
> a limit on the buffer? If I limit my read()s to 8192 bytes, should I

That's a server limit you have to pick. I don't really see what that
limit would have to do with the read() buffer size, it's completely
independent.

> The problem of receiving a half-stanza that's not well formed is still
> here.

To me, this means that you haven't solved the problem correctly, and
that you're still using the wrong type of parser that expects your
document to be complete. A real incremental parser never throws an
exception on an incomplete piece of XML of any kind. I'm also doubting
that you have the right test set to assume that your parser works.

> the exception and save the bad xml to the buffer and hope the next
> read() fixes it. This is also a DoS problem, if that stanza never gets
> fixed it'll keep raising the exception which will keep adding onto the
> buffer, which will keep raising the exception...

Again, that's a server limit you have to pick.

cheers,
Remko



More information about the JDev mailing list