From patchwork Fri Jun 10 02:48:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9168777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9C3B604DB for ; Fri, 10 Jun 2016 02:49:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF9A7281F9 for ; Fri, 10 Jun 2016 02:49:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2E862835E; Fri, 10 Jun 2016 02:49:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4661A281F9 for ; Fri, 10 Jun 2016 02:49:06 +0000 (UTC) Received: from localhost ([::1]:38082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBCVN-00025r-Db for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Jun 2016 22:49:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBCUm-00022k-Uf for qemu-devel@nongnu.org; Thu, 09 Jun 2016 22:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBCUk-0006wp-W5 for qemu-devel@nongnu.org; Thu, 09 Jun 2016 22:48:27 -0400 Received: from resqmta-po-03v.sys.comcast.net ([2001:558:fe16:19:96:114:154:162]:38809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBCUk-0006wd-QW for qemu-devel@nongnu.org; Thu, 09 Jun 2016 22:48:26 -0400 Received: from resomta-po-20v.sys.comcast.net ([96.114.154.244]) by resqmta-po-03v.sys.comcast.net with SMTP id BCUSb41LCRfBzBCUkbSrLI; Fri, 10 Jun 2016 02:48:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1465526906; bh=SkSr5EojzKx9MyPnQHgsoNHCyJ8tklZSb8DBReGSZkY=; h=Received:Received:From:To:Subject:Date:Message-Id; b=i0jf+ibdlaiz0WdKYoEGryyCt1nzo2q+ikgi0CJq9cWkMo5izWVHwHYV6DCpiQfUC e/ZPsEaCTTBUwQ/5JlGEcTBFJmEC9Q7li/uwq5NY36572kx3j6heWvUJXLb6hYKKmc E8JVztvBOsYFqqRnLAEZsC9XyFHKue4iuRqet9IEAEFcp5wuOv4LBwD/kMgQN54JVK 7co/Afolx0YW8Zh+cxwV6XfGDqRx6I26YWNjHtz6VNTyLFt10AnWv03fSePFJmvfcE q2gaaEWzCVb2HddEBnyATtwtLYB0E6BcJjEElUcmZrzMdnfT3luMVYIR4tz11xIhrQ /L2F/Lkgd+ojA== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-20v.sys.comcast.net with comcast id 4qo91t00F2fD5rL01qoRGj; Fri, 10 Jun 2016 02:48:26 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 9 Jun 2016 20:48:06 -0600 Message-Id: <1465526889-8339-2-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465526889-8339-1-git-send-email-eblake@redhat.com> References: <1465526889-8339-1-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:162 Subject: [Qemu-devel] [PATCH 1/4] qobject: Correct JSON lexer grammar comments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com, Luiz Capitulino Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fix the regex comments describing what we parse as JSON. No change to the lexer itself, just to the comments: - The "" and '' string construction was missing alternation between different escape sequences - The construction for numbers forgot to handle optional leading '-' - The construction for numbers was grouped incorrectly so that it didn't permit '0.1' - The construction for numbers forgot to mark the exponent as optional - No mention that our '' string and "\'" are JSON extensions - No mention of our %d and related extensions when constructing JSON Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster --- qobject/json-lexer.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index 496374d..ebd15d8 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -18,11 +18,22 @@ #define MAX_TOKEN_SIZE (64ULL << 20) /* - * \"([^\\\"]|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*\" - * '([^\\']|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*' - * 0|([1-9][0-9]*(.[0-9]+)?([eE]([-+])?[0-9]+)) + * Required by JSON (RFC 7159), plus \' extension in "": + * + * \"([^\\\"]|(\\\"|\\'|\\\\|\\/|\\b|\\f|\\n|\\r|\\t| + * \\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*\" + * -?(0|[1-9][0-9]*)(.[0-9]+)?([eE][-+]?[0-9]+)? * [{}\[\],:] - * [a-z]+ + * [a-z]+ # covers null, true, false + * + * Extension of '' strings: + * + * '([^\\']|(\\\"|\\'|\\\\|\\/|\\b|\\f|\\n|\\r|\\t| + * \\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*' + * + * Extension for vararg handling in JSON construction: + * + * %((l|ll|I64)?d|[ipsf]) * */ @@ -213,7 +224,7 @@ static const uint8_t json_lexer[][256] = { ['\t'] = IN_WHITESPACE, ['\r'] = IN_WHITESPACE, ['\n'] = IN_WHITESPACE, - }, + }, /* escape */ [IN_ESCAPE_LL] = {