[Python-checkins] CVS: python/dist/src/Lib quopri.py,1.12,1.13
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 19 Jun 2001 15:48:12 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv4201
Modified Files:
quopri.py
Log Message:
encode(): Fixed the handling of soft line breaks for lines over 76
characters in length. Remember that when calculating the soft breaks,
the trailing `=' sign counts against the max length!
Index: quopri.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** quopri.py 2001/06/19 19:07:46 1.12
--- quopri.py 2001/06/19 22:48:10 1.13
***************
*** 49,53 ****
prevline = None
- linelen = 0
while 1:
line = input.readline()
--- 49,52 ----
***************
*** 60,82 ****
line = line[:-1]
stripped = '\n'
for c in line:
if needsquoting(c, quotetabs):
c = quote(c)
- # Have we hit the RFC 1521 encoded line maximum?
- if linelen + len(c) >= MAXLINESIZE:
- # Write out the previous line
- if prevline is not None:
- write(prevline)
- prevline = EMPTYSTRING.join(outline)
- linelen = 0
- outline = []
outline.append(c)
! linelen += len(c)
! # Write out the current line
if prevline is not None:
write(prevline)
! prevline = EMPTYSTRING.join(outline)
! linelen = 0
! outline = []
# Write out the last line, without a trailing newline
if prevline is not None:
--- 59,80 ----
line = line[:-1]
stripped = '\n'
+ # Calculate the un-length-limited encoded line
for c in line:
if needsquoting(c, quotetabs):
c = quote(c)
outline.append(c)
! # First, write out the previous line
if prevline is not None:
write(prevline)
! # Now see if we need any soft line breaks because of RFC-imposed
! # length limitations. Then do the thisline->prevline dance.
! thisline = EMPTYSTRING.join(outline)
! while len(thisline) > MAXLINESIZE:
! # Don't forget to include the soft line break `=' sign in the
! # length calculation!
! write(thisline[:MAXLINESIZE-1], lineEnd='=\n')
! thisline = thisline[MAXLINESIZE-1:]
! # Write out the current line
! prevline = thisline
# Write out the last line, without a trailing newline
if prevline is not None: