aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-07-27 17:41:57 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-07-29 10:37:11 -0500
commit9213aa5391f7c8d3766420d96888f1353af4c890 (patch)
tree93d0bfe561e2e71efbf8388b0ebc3ffb3732117d
parent2caba36cc61ee3993334bc423f0852f8006fdfcf (diff)
qapi.py: Reject invalid characters in schema file
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1374939721-7876-6-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--scripts/qapi.py2
-rw-r--r--tests/qapi-schema/comments.err1
-rw-r--r--tests/qapi-schema/comments.exit2
-rw-r--r--tests/qapi-schema/comments.out3
-rw-r--r--tests/qapi-schema/funny-char.err1
-rw-r--r--tests/qapi-schema/funny-char.exit2
-rw-r--r--tests/qapi-schema/funny-char.out3
7 files changed, 6 insertions, 8 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 342d16c4e8..0b48a1e50a 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -101,6 +101,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/comments.err b/tests/qapi-schema/comments.err
index e69de29bb2..4a82b26d0f 100644
--- a/tests/qapi-schema/comments.err
+++ b/tests/qapi-schema/comments.err
@@ -0,0 +1 @@
+<stdin>:2:33: Stray "#"
diff --git a/tests/qapi-schema/comments.exit b/tests/qapi-schema/comments.exit
index 573541ac97..d00491fd7e 100644
--- a/tests/qapi-schema/comments.exit
+++ b/tests/qapi-schema/comments.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index e3bd904453..e69de29bb2 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]
diff --git a/tests/qapi-schema/funny-char.err b/tests/qapi-schema/funny-char.err
index e69de29bb2..d3dd293faf 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 573541ac97..d00491fd7e 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 e3bd904453..e69de29bb2 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']
-[]