diff mbox

[5/9] qapi.py: Reject invalid characters in schema file

Message ID 1374842387-17146-6-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster July 26, 2013, 12:39 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py                   | 2 ++
 tests/qapi-schema/funny-char.err  | 1 +
 tests/qapi-schema/funny-char.exit | 2 +-
 tests/qapi-schema/funny-char.out  | 3 ---
 4 files changed, 4 insertions(+), 4 deletions(-)

Comments

Eric Blake July 26, 2013, 3:32 p.m. UTC | #1
On 07/26/2013 06:39 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/qapi.py                   | 2 ++
>  tests/qapi-schema/funny-char.err  | 1 +
>  tests/qapi-schema/funny-char.exit | 2 +-
>  tests/qapi-schema/funny-char.out  | 3 ---
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 

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

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 35ff76e..f72a0e3 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -86,6 +86,8 @@  class QAPISchema:
                 if self.cursor == len(self.src):
                     self.tok = None
                     return
+            elif not self.tok.isspace():
+                raise QAPISchemaError(self, 'Stray "%s"' % self.tok)
 
     def get_members(self):
         expr = OrderedDict()
diff --git a/tests/qapi-schema/funny-char.err b/tests/qapi-schema/funny-char.err
index e69de29..d3dd293 100644
--- a/tests/qapi-schema/funny-char.err
+++ b/tests/qapi-schema/funny-char.err
@@ -0,0 +1 @@ 
+<stdin>:2:36: Stray ";"
diff --git a/tests/qapi-schema/funny-char.exit b/tests/qapi-schema/funny-char.exit
index 573541a..d00491f 100644
--- a/tests/qapi-schema/funny-char.exit
+++ b/tests/qapi-schema/funny-char.exit
@@ -1 +1 @@ 
-0
+1
diff --git a/tests/qapi-schema/funny-char.out b/tests/qapi-schema/funny-char.out
index e3bd904..e69de29 100644
--- a/tests/qapi-schema/funny-char.out
+++ b/tests/qapi-schema/funny-char.out
@@ -1,3 +0,0 @@ 
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]