From 47404fffff3e36699786082d0ee6565872d627e1 Mon Sep 17 00:00:00 2001 From: Piers Lauder Date: Tue, 29 Apr 2003 23:40:59 +0000 Subject: added code to canonicalise line endings in data sent via "append" - fix for bug report 723962 --- Lib/imaplib.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Lib/imaplib.py') diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 12c19a05a11..9f82e2b3a9c 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -83,6 +83,7 @@ r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])' r'"') Literal = re.compile(r'.*{(?P\d+)}$') +MapCRLF = re.compile(r'(?:\r\n|\n|\r(?!\n))') Response_code = re.compile(r'\[(?P[A-Z-]+)( (?P[^\]]*))?\]') Untagged_response = re.compile(r'\* (?P[A-Z-]+)( (?P.*))?') Untagged_status = re.compile(r'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?') @@ -308,7 +309,7 @@ def append(self, mailbox, flags, date_time, message): date_time = Time2Internaldate(date_time) else: date_time = None - self.literal = message + self.literal = MapCRLF.sub(CRLF, message) return self._simple_command(name, mailbox, flags, date_time) @@ -1360,7 +1361,7 @@ def Time2Internaldate(date_time): USER = getpass.getuser() PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "localhost")) - test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':CRLF} + test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':'\n'} test_seq1 = ( ('login', (USER, PASSWD)), ('create', ('/tmp/xxx 1',)), -- cgit v1.2.3-65-gdbad