All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2 06/16] qapi: Restrict strings to printable ASCII
Date: Tue, 10 Sep 2019 10:22:32 -0500	[thread overview]
Message-ID: <fedc30f3-4b34-4a1d-8791-a294b9cdc646@redhat.com> (raw)
In-Reply-To: <20190910063724.28470-7-armbru@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1925 bytes --]

On 9/10/19 1:37 AM, Markus Armbruster wrote:
> RFC 8259 on string contents:
> 
>    All Unicode characters may be placed within the quotation marks,
>    except for the characters that MUST be escaped: quotation mark,
>    reverse solidus, and the control characters (U+0000 through
>    U+001F).
> 
> The QAPI schema parser accepts both less and more than JSON: it
> accepts only ASCII with \u (less), and accepts control characters
> other than LF (new line) unescaped.  How it treats unescaped non-ASCII
> input differs between Python 2 and Python 3.
> 
> Make it accept strictly less: require printable ASCII.  Drop support
> for \b, \f, \n, \r, \t.

Fair enough.  It doesn't prevent QMP clients from sending strings with
non-ASCII characters, merely that those strings will never match the
schema because we have guaranteed our schema is limited to ASCII.  (This
change means we are promising to never allow { "execute": "a\tb" } as a
valid QMP command, for instance.)

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

> @@ -523,17 +523,7 @@ class QAPISchemaParser(object):
>                      if ch == '\n':
>                          raise QAPIParseError(self, 'Missing terminating "\'"')
>                      if esc:
> -                        if ch == 'b':
> -                            string += '\b'
> -                        elif ch == 'f':
> -                            string += '\f'
> -                        elif ch == 'n':
> -                            string += '\n'

Is it worth a comment in the code that we are specifically not parsing
all possible JSON escapes, because of the later requirement that QAPI
strings be limited to the subset of printable ASCII?

Reviewed-by: Eric Blake <eblake@redhat.com>

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-09-10 15:23 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10  6:37 [Qemu-devel] [PATCH v2 00/16] qapi: Schema language cleanups & doc improvements Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 01/16] scripts/git.orderfile: Match QAPI schema more precisely Markus Armbruster
2019-09-10  6:56   ` Philippe Mathieu-Daudé
2019-09-10 13:41   ` Eric Blake
2019-09-13 14:14     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 02/16] qapi: Drop check_type()'s redundant parameter @allow_optional Markus Armbruster
2019-09-10 13:45   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 03/16] qapi: Drop support for boxed alternate arguments Markus Armbruster
2019-09-10 14:54   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 04/16] docs/devel/qapi-code-gen: Minor specification fixes Markus Armbruster
2019-09-10 15:10   ` Eric Blake
2019-09-13 14:23     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 05/16] tests/qapi-schema: Demonstrate bad reporting of funny characters Markus Armbruster
2019-09-10 15:12   ` Eric Blake
2019-09-13 14:24     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 06/16] qapi: Restrict strings to printable ASCII Markus Armbruster
2019-09-10 15:22   ` Eric Blake [this message]
2019-09-13 14:28     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 07/16] qapi: Drop support for escape sequences other than \\ Markus Armbruster
2019-09-10 15:28   ` Eric Blake
2019-09-13 14:38     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 08/16] qapi: Permit 'boxed' with empty type Markus Armbruster
2019-09-10 16:28   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 09/16] qapi: Permit alternates with just one branch Markus Armbruster
2019-09-10 16:30   ` Eric Blake
2019-09-13 14:47     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 10/16] qapi: Permit omitting all flat union branches Markus Armbruster
2019-09-10 16:32   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 11/16] qapi: Adjust frontend errors to say enum value, not member Markus Armbruster
2019-09-10 16:33   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 12/16] docs/devel/qapi-code-gen: Reorder sections for readability Markus Armbruster
2019-09-10 16:36   ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 13/16] docs/devel/qapi-code-gen: Rewrite compatibility considerations Markus Armbruster
2019-09-10 16:42   ` Eric Blake
2019-09-13 15:05     ` Markus Armbruster
2019-09-17 16:11       ` Eric Blake
2019-09-23 11:44         ` Markus Armbruster
2019-09-23 13:00           ` Eric Blake
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 14/16] docs/devel/qapi-code-gen: Rewrite introduction to schema Markus Armbruster
2019-09-10 16:50   ` Eric Blake
2019-09-13 15:16     ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 15/16] docs/devel/qapi-code-gen: Improve QAPI schema language doc Markus Armbruster
2019-09-10 17:37   ` Eric Blake
2019-09-13 15:39     ` Markus Armbruster
2019-09-17 16:14       ` Eric Blake
2019-09-23 11:45         ` Markus Armbruster
2019-09-10  6:37 ` [Qemu-devel] [PATCH v2 16/16] qapi: Tweak code to match docs/devel/qapi-code-gen.txt Markus Armbruster
2019-09-10 17:45   ` Eric Blake
2019-09-10  7:09 ` [Qemu-devel] [PATCH v2 00/16] qapi: Schema language cleanups & doc improvements no-reply
2019-09-10 22:32 ` no-reply

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=fedc30f3-4b34-4a1d-8791-a294b9cdc646@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.