Browse Source

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>
Markus Armbruster 12 năm trước cách đây
mục cha
commit
9213aa5391

+ 2 - 0
scripts/qapi.py

@@ -101,6 +101,8 @@ def accept(self):
                 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()

+ 1 - 0
tests/qapi-schema/comments.err

@@ -0,0 +1 @@
+<stdin>:2:33: Stray "#"

+ 1 - 1
tests/qapi-schema/comments.exit

@@ -1 +1 @@
-0
+1

+ 0 - 3
tests/qapi-schema/comments.out

@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]

+ 1 - 0
tests/qapi-schema/funny-char.err

@@ -0,0 +1 @@
+<stdin>:2:36: Stray ";"

+ 1 - 1
tests/qapi-schema/funny-char.exit

@@ -1 +1 @@
-0
+1

+ 0 - 3
tests/qapi-schema/funny-char.out

@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]