From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ykvoc-0008RP-L6 for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:39:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkvoY-0000Wt-I2 for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:39:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkvoY-0000Wm-8H for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:39:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3MEdjah024635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 22 Apr 2015 10:39:45 -0400 Message-ID: <5537B2B0.6080805@redhat.com> Date: Wed, 22 Apr 2015 10:39:44 -0400 From: John Snow MIME-Version: 1.0 References: <1429668155-1606-1-git-send-email-jsnow@redhat.com> <1429668155-1606-4-git-send-email-jsnow@redhat.com> <5537B176.9070508@redhat.com> In-Reply-To: <5537B176.9070508@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/5] scripts: qmp-shell: allow single-quotes in JSON expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: kchamart@redhat.com, lcapitulino@redhat.com On 04/22/2015 10:34 AM, Eric Blake wrote: > On 04/21/2015 08:02 PM, John Snow wrote: >> As a convenience for the user, replace any single quotes given >> with double quotes so that the data will deserialize correctly >> via json.loads(). >> >> Signed-off-by: John Snow >> --- >> scripts/qmp/qmp-shell | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell >> index 5347f89..d7cb33d 100755 >> --- a/scripts/qmp/qmp-shell >> +++ b/scripts/qmp/qmp-shell >> @@ -129,7 +129,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): >> >> < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ] >> """ >> - cmdargs = cmdline.split() >> + cmdargs = cmdline.replace("'", '"').split() > > This replaces ALL single quotes, even if they would otherwise be > escaped. That is, if I pass foo="a\'\"b", it will probably be corrupted. > > qmp-shell exists mainly as a convenience for testing, and I doubt > testers are likely to want to use unbalanced quotes as contents of > strings, so I can give a weak: > Reviewed-by: Eric Blake > > But it's still worth thinking about whether there is a more robust > solution to be used. > Oh, hmm. I naively assumed that such quotes weren't permissable within the namespace for any valid QMP commands, but... There's a lot of simplifying assumptions within qmp-shell already and I was really hoping to avoid re-architecting the parser where I just wanted to add a few "hit and run" improvements. This patch could be dropped if it poses a serious problem; mostly I wanted to ensure that QMP commands could be entered as they are displayed (with single quotes!) I'll look briefly to see if there's a quick win-button for converting the quotes in a "safe" way. --js