diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-06-29 18:40:53 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-06-29 18:40:53 -0400 |
commit | 925a3225708c40c8cd58a7475c5a6d3bd89db01d (patch) | |
tree | d55f128b7c4b5b6757c6d2c96f5e6a62a54a4243 /Lib/csv.py | |
parent | e4e530e7e8fa6883e553c898ea063dae82535fd1 (diff) | |
download | cpython-git-925a3225708c40c8cd58a7475c5a6d3bd89db01d.tar.gz |
#18155: Regex-escape delimiter, in case it is a regex special char.
Patch by Vajrasky Kok, with slight modification to the tests by me.
Diffstat (limited to 'Lib/csv.py')
-rw-r--r-- | Lib/csv.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/csv.py b/Lib/csv.py index 8dfc77e310..da3bc44e7a 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -264,8 +264,9 @@ class Sniffer: # if we see an extra quote between delimiters, we've got a # double quoted format - dq_regexp = re.compile(r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ - {'delim':delim, 'quote':quotechar}, re.MULTILINE) + dq_regexp = re.compile( + r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ + {'delim':re.escape(delim), 'quote':quotechar}, re.MULTILINE) |