#18155: Regex-escape delimiter, in case it is a regex special char.
Patch by Vajrasky Kok, with slight modification to the tests by me.
diff --git a/Lib/csv.py b/Lib/csv.py
index 984ed7e..98480ba 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -261,8 +261,9 @@
# 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)