summaryrefslogtreecommitdiff
path: root/Lib/csv.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-06-29 18:42:24 -0400
committerR David Murray <rdmurray@bitdance.com>2013-06-29 18:42:24 -0400
commit634e076bbe08de3b5b4dfc2a1e10a20b64114ac1 (patch)
tree4f1ff4125ddc40af6ed8a17baa033d57937693f3 /Lib/csv.py
parent06beaba785b78cc89986b447ef2bb7be4f7a7696 (diff)
parent925a3225708c40c8cd58a7475c5a6d3bd89db01d (diff)
downloadcpython-git-634e076bbe08de3b5b4dfc2a1e10a20b64114ac1.tar.gz
Merge #18155: Regex-escape delimiter, in case it is a regex special char.
Diffstat (limited to 'Lib/csv.py')
-rw-r--r--Lib/csv.py5
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)