[Python-checkins] python/dist/src/Lib/email Header.py,1.14,1.15
bwarsaw@users.sourceforge.net
bwarsaw@users.sourceforge.net
Mon, 14 Oct 2002 08:13:29 -0700
Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv25569/email
Modified Files:
Header.py
Log Message:
__init__(): Fix an invariant, that the charset item in a chunk tuple
must be a Charset instance, not a string. The bug here was that
self._charset wasn't being converted to a Charset instance so later
.append() calls which used the default charset would break.
_split(): If the charset of the chunk is '8bit', return the chunk
unchanged. We can't safely split it, so this is the avenue of least
harm.
Index: Header.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Header.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Header.py 13 Oct 2002 04:06:28 -0000 1.14
--- Header.py 14 Oct 2002 15:13:17 -0000 1.15
***************
*** 154,157 ****
--- 154,159 ----
if charset is None:
charset = USASCII
+ if not isinstance(charset, Charset):
+ charset = Charset(charset)
self._charset = charset
self._continuation_ws = continuation_ws
***************
*** 234,239 ****
def _split(self, s, charset, firstline=False):
! # Split up a header safely for use with encode_chunks. BAW: this
! # appears to be a private convenience method.
splittable = charset.to_splittable(s)
encoded = charset.from_splittable(splittable)
--- 236,240 ----
def _split(self, s, charset, firstline=False):
! # Split up a header safely for use with encode_chunks.
splittable = charset.to_splittable(s)
encoded = charset.from_splittable(splittable)
***************
*** 242,245 ****
--- 243,254 ----
if elen <= self._maxlinelen:
return [(encoded, charset)]
+ # If we have undetermined raw 8bit characters sitting in a byte
+ # string, we really don't know what the right thing to do is. We
+ # can't really split it because it might be multibyte data which we
+ # could break if we split it between pairs. The least harm seems to
+ # be to not split the header at all, but that means they could go out
+ # longer than maxlinelen.
+ elif charset == '8bit':
+ return [(s, charset)]
# BAW: I'm not sure what the right test here is. What we're trying to
# do is be faithful to RFC 2822's recommendation that ($2.2.3):