diff options
author | Marko Kreen | 2011-06-21 07:46:23 +0000 |
---|---|---|
committer | Marko Kreen | 2011-06-21 07:46:23 +0000 |
commit | 8746362357b20dab3ddc430aa161b603aceffaa8 (patch) | |
tree | 8330c732e273c16eca4e2d0203d276ebfe6703d6 | |
parent | 35a9539921a067c9a579a1b4b5bd46d7b3371752 (diff) |
parse_pgarray: more strict error checking
-rw-r--r-- | python/skytools/parsing.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/python/skytools/parsing.py b/python/skytools/parsing.py index 7ca1c498..cf491417 100644 --- a/python/skytools/parsing.py +++ b/python/skytools/parsing.py @@ -43,6 +43,8 @@ def parse_pgarray(array): val = None else: if len(item) > 0 and item[0] == '"': + if len(item) == 1 or item[-1] != '"': + raise Exception("bad array format: broken '\"'") item = item[1:-1] val = skytools.unescape(item) res.append(val) @@ -52,6 +54,8 @@ def parse_pgarray(array): break elif array[pos2] != ",": raise Exception("bad array format: expected ,} got " + repr(array[pos2])) + if pos < len(array) - 1: + raise Exception("bad array format: failed to parse completely (pos=%d len=%d)" % (pos, len(array))) return res # |