summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2011-09-19 08:43:09 +0000
committerMarko Kreen2011-09-19 08:43:09 +0000
commitc6dc7723b2f7fb2ce8e22b9f56b4b28b42d79c2d (patch)
treefd815f9b2e0906fb2f82536a44ad9d9245f9a061
parent8d2c4e2d70881c1bd57ff5d96571096fd35fc02f (diff)
qadmin: better ident unquoting
old one did fail on '.' inside "".
-rwxr-xr-xpython/qadmin.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/python/qadmin.py b/python/qadmin.py
index 7d35da0c..608de5cd 100755
--- a/python/qadmin.py
+++ b/python/qadmin.py
@@ -118,10 +118,26 @@ IGNORE_HOSTS = {
'ip6-mcastprefix': 1,
}
+_ident_rx =''' ( " ( "" | [^"]+ )* " ) | ( [a-z_][a-z0-9_]* ) | [.] | (?P<err> .) '''
+_ident_rc = re.compile(_ident_rx, re.X | re.I)
+
def unquote_any(typ, s):
+ global _ident_rc
if typ == 'ident':
- ps = [skytools.unquote_ident(p) for p in s.split('.')]
- s = '.'.join(ps)
+ res = []
+ pos = 0
+ while 1:
+ m = _ident_rc.match(s, pos)
+ if not m:
+ break
+ if m.group('err'):
+ raise Exception('invalid syntax for ident')
+ s1 = m.group()
+ if s1[0] == '"':
+ s1 = s1[1:-1].replace('""', '"')
+ res.append(s1)
+ pos = m.end()
+ s = ''.join(res)
elif typ == 'str' or typ == 'dolq':
s = skytools.unquote_literal(s, True)
return s