summaryrefslogtreecommitdiff
path: root/scripts/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-09-13 22:13:40 +0200
committerMarkus Armbruster <armbru@redhat.com>2019-09-24 14:07:22 +0200
commit9b4416bfc1ea5fb3398e8f78a90caa88dd301c37 (patch)
treef9f7873635cf4f07f9f55e42d8dbbb34df058778 /scripts/qapi
parent56a8caff922df8d597895a49f55f2150bff3adb7 (diff)
downloadqemu-9b4416bfc1ea5fb3398e8f78a90caa88dd301c37.zip
qapi: Drop support for escape sequences other than \\
Since the previous commit restricted strings to printable ASCII, \uXXXX's only use is obfuscation. Drop it. This leaves \\, \/, \', and \". Since QAPI schema strings are all names, and names are restricted to ASCII letters, digits, hyphen, and underscore, none of them is useful. The latter three have no test coverage. Drop them. Keep \\ to avoid (more) gratuitous incompatibility with JSON. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190913201349.24332-8-armbru@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r--scripts/qapi/common.py26
1 files changed, 3 insertions, 23 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 539b50f9ac..0fb1d1956a 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -524,29 +524,9 @@ class QAPISchemaParser(object):
if ch == '\n':
raise QAPIParseError(self, 'Missing terminating "\'"')
if esc:
- # Note: we don't recognize escape sequences
- # for control characters
- if ch == 'u':
- value = 0
- for _ in range(0, 4):
- ch = self.src[self.cursor]
- self.cursor += 1
- if ch not in '0123456789abcdefABCDEF':
- raise QAPIParseError(self,
- '\\u escape needs 4 '
- 'hex digits')
- value = (value << 4) + int(ch, 16)
- # If Python 2 and 3 didn't disagree so much on
- # how to handle Unicode, then we could allow
- # Unicode string defaults. But most of QAPI is
- # ASCII-only, so we aren't losing much for now.
- if not value or value > 0x7f:
- raise QAPIParseError(self,
- 'For now, \\u escape '
- 'only supports non-zero '
- 'values up to \\u007f')
- ch = chr(value)
- elif ch not in '\\/\'"':
+ # Note: we recognize only \\ because we have
+ # no use for funny characters in strings
+ if ch != '\\':
raise QAPIParseError(self,
"Unknown escape \\%s" % ch)
esc = False