summaryrefslogtreecommitdiffstats
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
authorPiers Lauder <piers@cs.su.oz.au>2003-04-29 23:40:59 (GMT)
committerPiers Lauder <piers@cs.su.oz.au>2003-04-29 23:40:59 (GMT)
commit47404fffff3e36699786082d0ee6565872d627e1 (patch)
tree1e4910884e09e49343938104993550f2c6597243 /Lib/imaplib.py
parent75ab1462d5725a2fc46cd56f07fc21f919ca93e0 (diff)
downloadcpython-47404fffff3e36699786082d0ee6565872d627e1.zip
cpython-47404fffff3e36699786082d0ee6565872d627e1.tar.gz
cpython-47404fffff3e36699786082d0ee6565872d627e1.tar.bz2
added code to canonicalise line endings in data sent via "append" - fix for bug report 723962
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 12c19a0..9f82e2b 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -83,6 +83,7 @@ InternalDate = re.compile(r'.*INTERNALDATE "'
r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
r'"')
Literal = re.compile(r'.*{(?P<size>\d+)}$')
+MapCRLF = re.compile(r'(?:\r\n|\n|\r(?!\n))')
Response_code = re.compile(r'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
Untagged_response = re.compile(r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
Untagged_status = re.compile(r'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?')
@@ -308,7 +309,7 @@ class IMAP4:
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 @@ if __name__ == '__main__':
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',)),