[issue1974] email.MIMEText.MIMEText.as_string incorrectly folding long subject header

Andi Albrecht report at bugs.python.org
Mon Jun 23 16:45:34 CEST 2008


Andi Albrecht <albrecht.andi at gmail.com> added the comment:

IMO, the best way to resolve this is to use the default continuation
whitespace when a Header class is created from a string. But I'm pretty
unsure about the default whitespace character. After having a look at a
random set of mails in my inbox it seems that in most cases a tab is
used for all headers except for the subject (excluding mails sent from
Python scripts of course...). I would prefer '\t'; it's allowed and
results in a cleaner output - but it won't solve the problem with some
email clients which was the starting point for this issue (a short note
in the docs should resolve this anyway... ;-)

But I wonder if for some reason setting headers from strings
intentionally differs from using the Header class? There are some tests
that explicitly test both cases and expect different output. In
TestLongHeaders it's

 test_long_unbreakable_lines_with_continuation()
 test_long_lines_with_different_header(self)
 test_long_received_header() [continuation_ws set to tab here]

So, what I would do is
 * remove continuation_ws keyword from Generator._write_headers()
 * make '\t' the default cont. whitespace for headers (Header class)
 * update test cases and the documentation accordingly

Do you think that this is the right way to go? Or would it break too
much code outside stdlib if the default ws changes?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1974>
_______________________________________


More information about the Python-bugs-list mailing list