qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: ANN: QEMU Monitor Protocol git tree


From: Paolo Bonzini
Subject: [Qemu-devel] Re: ANN: QEMU Monitor Protocol git tree
Date: Wed, 23 Sep 2009 15:40:26 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3

On 09/23/2009 12:57 PM, Avi Kivity wrote:
On 09/23/2009 12:57 PM, Daniel P. Berrange wrote:
Ignoring the dos-ism, since you can parse JSON with a regexp, why do we
need explicit message boundaries?
I think it would be nice to be able to assume that each JSON message
will not cross a line-end boundary. Whether we use CRLF, just CR or
just LF I don't mind. Its much easier to search for a message boundary
by just doing strchr('\n') than having to actually parse the JSON or
use a regexp at that point.

A good parser will consume exactly enough characters to make up an
object or let you know if it needs more. I don't think using a regexp is
warranted.

Agreed, regexes are unnecessary. Also because a regex cannot parse JSON; it can only detect _some_ invalid JSON inputs, and then only if you're given an already complete input.

In other words, there are Javascript JSON parsers that are just "match a regexp and run eval on the input", but the actual parsing is done by the Javascript interpreter using eval. The regexp is just avoiding the security problems that are inherent in eval.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]