summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-09-26 22:53:02 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-11-05 09:34:50 +0000
commitaf835f885710a89c54a2ec04c87f7e3df4d6f29f (patch)
treed8d23c640592124af81b684bda2012cae65c78e8 /lib
parent70880dde7911c4f170f720d56851807c0672a1a3 (diff)
downloadpsycopg2-af835f885710a89c54a2ec04c87f7e3df4d6f29f.tar.gz
Correctly parse escaped quotes from hstore.
Parse regexp simplified.
Diffstat (limited to 'lib')
-rw-r--r--lib/extras.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 0af5868..d9872c5 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -523,18 +523,13 @@ class HstoreAdapter(object):
_re_hstore = regex.compile(r"""
# hstore key:
- "( # catch in quotes
- (?: # many of
- [^"] # either not a quote
- # or a quote escaped, i.e. preceded by an odd number of backslashes
- | [^\\] (?:\\\\)* \\"
- )*
- )"
+ # a string of normal or escaped chars
+ "((?: [^"\\] | \\. )*)"
\s*=>\s* # hstore value
(?:
NULL # the value can be null - not catched
- # or the same quoted string of the key
- | "((?:[^"] | [^\\] (?:\\\\)* \\" )*)"
+ # or a quoted string like the key
+ | "((?: [^"\\] | \\. )*)"
)
(?:\s*,\s*|$) # pairs separated by comma or end of string.
""", regex.VERBOSE)