qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 41/60] json: Nicer recovery from invalid lead


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 41/60] json: Nicer recovery from invalid leading zero
Date: Fri, 17 Aug 2018 11:03:21 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 08/17/2018 10:05 AM, Markus Armbruster wrote:
For input 0123, the lexer produces the tokens

     JSON_ERROR    01
     JSON_INTEGER  23

Reporting an error is correct; 0123 is invalid according to RFC 7159.
But the error recovery isn't nice.

Make the finite state machine eat digits before going into the error
state.  The lexer now produces

     JSON_ERROR    0123

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>

Did you also want to reject invalid attempts at hex numbers, by adding [xXa-fA-F] to the set of characters eaten by IN_BAD_ZERO?

+ [IN_BAD_ZERO] = {
+        ['0' ... '9'] = IN_BAD_ZERO,
+    },
+


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

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