[3.12] gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741) (GH-115866)

(cherry picked from commit c688c0f130)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-02-23 21:45:04 +01:00 committed by GitHub
parent 10907bdad3
commit 4ac657a62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 15 deletions

View file

@ -1109,6 +1109,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) {