[3.14] gh-78319: Fix implementation of IMAP APPEND UTF8 (GH-9436) (GH-139406)

Make UTF8 support for the IMAP APPEND command RFC 6855 compliant.
(cherry picked from commit 408154d64a)

Co-authored-by: Gordon Messmer <gordon.messmer@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-10-07 22:12:30 +02:00 committed by GitHub
parent f0f0566292
commit 89a7b05f23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View file

@ -497,8 +497,6 @@ class IMAP4:
else:
date_time = None
literal = MapCRLF.sub(CRLF, message)
if self.utf8_enabled:
literal = b'UTF8 (' + literal + b')'
self.literal = literal
return self._simple_command(name, mailbox, flags, date_time)
@ -1119,7 +1117,11 @@ class IMAP4:
literator = literal
else:
literator = None
data = data + bytes(' {%s}' % len(literal), self._encoding)
if self.utf8_enabled:
data = data + bytes(' UTF8 (~{%s}' % len(literal), self._encoding)
literal = literal + b')'
else:
data = data + bytes(' {%s}' % len(literal), self._encoding)
if __debug__:
if self.debug >= 4: