qapi: Fix to reject stray 't', 'f' and 'n'
authorMarkus Armbruster <armbru@redhat.com>
Wed, 10 Jun 2015 06:24:58 +0000 (08:24 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 18 Jun 2015 12:19:34 +0000 (14:19 +0200)
Screwed up in commit e53188a.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
scripts/qapi.py

index a24a7e2778670f1dc09842d197a28e3004a5d2fc..6faa897fa67be189424c7cbdc2cb425ddb81fc35 100644 (file)
@@ -217,20 +217,18 @@ class QAPISchema:
                         return
                     else:
                         string += ch
-            elif self.tok in "tfn":
-                val = self.src[self.cursor - 1:]
-                if val.startswith("true"):
-                    self.val = True
-                    self.cursor += 3
-                    return
-                elif val.startswith("false"):
-                    self.val = False
-                    self.cursor += 4
-                    return
-                elif val.startswith("null"):
-                    self.val = None
-                    self.cursor += 3
-                    return
+            elif self.src.startswith("true", self.pos):
+                self.val = True
+                self.cursor += 3
+                return
+            elif self.src.startswith("false", self.pos):
+                self.val = False
+                self.cursor += 4
+                return
+            elif self.src.startswith("null", self.pos):
+                self.val = None
+                self.cursor += 3
+                return
             elif self.tok == '\n':
                 if self.cursor == len(self.src):
                     self.tok = None