From: John Snow <jsnow@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com, Cleber Rosa <crosa@redhat.com>,
ehabkost@redhat.com, kchamart@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qmp-shell: fix nested json regression
Date: Fri, 8 Mar 2019 17:50:18 -0500 [thread overview]
Message-ID: <9b037d46-8e73-e5ee-49f2-0c79f06e758f@redhat.com> (raw)
In-Reply-To: <20190205134926.8312-1-marcandre.lureau@redhat.com>
On 2/5/19 8:49 AM, Marc-André Lureau wrote:
> Commit fcfab7541 ("qmp-shell: learn to send commands with quoted
> arguments") introduces the usage of Python 'shlex' to handle quoted
> arguments, but it accidentally broke generation of nested JSON
> structs.
>
> shlex drops quotes, which breaks parsing of the nested struct.
>
> cmd='blockdev-create job-id="job0 foo" options={"driver":"qcow2","size":16384,"file":{"driver":"file","filename":"foo.qcow2"}}'
>
> shlex.split(cmd)
> ['blockdev-create',
> 'job-id=job0 foo',
> 'options={driver:qcow2,size:16384,file:{driver:file,filename:foo.qcow2}}']
>
> Replace with a regexp to split while respecting quoted strings and preserving quotes:
>
> re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''', cmd)
> ['blockdev-create',
> 'job-id="job0 foo"',
> 'options={"driver":"qcow2","size":16384,"file":{"driver":"file","filename":"foo.qcow2"}}']
>
> Fixes: fcfab7541 ("qmp-shell: learn to send commands with quoted arguments")
> Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Hi, did this get misplaced? Would be nice to have back for 4.0 release.
next prev parent reply other threads:[~2019-03-08 22:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-05 13:49 [Qemu-devel] [PATCH] qmp-shell: fix nested json regression Marc-André Lureau
2019-02-06 1:44 ` John Snow
2019-02-06 10:48 ` Kashyap Chamarthy
2019-02-06 11:09 ` Kashyap Chamarthy
2019-03-08 22:50 ` John Snow [this message]
2019-03-09 9:01 ` Markus Armbruster
2019-03-11 13:27 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b037d46-8e73-e5ee-49f2-0c79f06e758f@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kchamart@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).