summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-03-06 05:14:20 (GMT)
committerBarry Warsaw <barry@python.org>2003-03-06 05:14:20 (GMT)
commit0ed81c35a79209405df249921b3382ddef6284ff (patch)
tree1e2858032ba173663c9200a4da47f5e238c4de5b /Lib/email
parente8577b7298c758966e685bf068a148746608de85 (diff)
downloadcpython-0ed81c35a79209405df249921b3382ddef6284ff.zip
cpython-0ed81c35a79209405df249921b3382ddef6284ff.tar.gz
cpython-0ed81c35a79209405df249921b3382ddef6284ff.tar.bz2
Merge of the folding-reimpl-branch. Specific changes,
_max_append(): Change the comparison so that the new string is concatenated if it's less than or equal to the max length. header_encode(): Allow for maxlinelen == None to mean, don't do any line splitting. This is because this module is mostly used by higher level abstractions (Header.py) which already ensures line lengths. We do this in a cheapo way by setting the max_encoding to some insanely <100k wink> large number.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/quopriMIME.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/email/quopriMIME.py b/Lib/email/quopriMIME.py
index 18ddd89..67369b5 100644
--- a/Lib/email/quopriMIME.py
+++ b/Lib/email/quopriMIME.py
@@ -82,7 +82,7 @@ def body_quopri_len(str):
def _max_append(L, s, maxlen, extra=''):
if not L:
L.append(s.lstrip())
- elif len(L[-1]) + len(s) < maxlen:
+ elif len(L[-1]) + len(s) <= maxlen:
L[-1] += extra + s
else:
L.append(s.lstrip())
@@ -116,7 +116,8 @@ def header_encode(header, charset="iso-8859-1", keep_eols=False,
=?charset?q?Silly_=C8nglish_Kn=EEghts?="
with each line wrapped safely at, at most, maxlinelen characters (defaults
- to 76 characters).
+ to 76 characters). If maxlinelen is None, the entire string is encoded in
+ one chunk with no splitting.
End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted
to the canonical email line separator \\r\\n unless the keep_eols
@@ -134,9 +135,13 @@ def header_encode(header, charset="iso-8859-1", keep_eols=False,
header = fix_eols(header)
# Quopri encode each line, in encoded chunks no greater than maxlinelen in
- # lenght, after the RFC chrome is added in.
+ # length, after the RFC chrome is added in.
quoted = []
- max_encoded = maxlinelen - len(charset) - MISC_LEN
+ if maxlinelen is None:
+ # An obnoxiously large number that's good enough
+ max_encoded = 100000
+ else:
+ max_encoded = maxlinelen - len(charset) - MISC_LEN - 1
for c in header:
# Space may be represented as _ instead of =20 for readability