summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-02-23 20:25:09 (GMT)
committerGitHub <noreply@github.com>2024-02-23 20:25:09 (GMT)
commitc688c0f130906ff7725a126fff143d1389884f89 (patch)
treefaf7196a6a37744f941716379e8708f1bd190854 /Modules/_csv.c
parent462a2fc09d9e5f7cdd3a8f2faed73e5bc2c93349 (diff)
downloadcpython-c688c0f130906ff7725a126fff143d1389884f89.zip
cpython-c688c0f130906ff7725a126fff143d1389884f89.tar.gz
cpython-c688c0f130906ff7725a126fff143d1389884f89.tar.bz2
gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741)
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 8d04728..660c545 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -1152,6 +1152,8 @@ join_append_data(WriterObj *self, int field_kind, const void *field_data,
if (c == dialect->delimiter ||
c == dialect->escapechar ||
c == dialect->quotechar ||
+ c == '\n' ||
+ c == '\r' ||
PyUnicode_FindChar(
dialect->lineterminator, c, 0,
PyUnicode_GET_LENGTH(dialect->lineterminator), 1) >= 0) {