[ python-Bugs-1372770 ] email.Header should preserve original FWS

SourceForge.net noreply at sourceforge.net
Mon Nov 6 08:50:15 CET 2006


Bugs item #1372770, was opened at 2005-12-04 10:53
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1372770&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nathan Herring (nherring)
>Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email.Header should preserve original FWS

Initial Comment:
The Header class describes its operation as using the continuation_ws 
parameter, prepending the value to continuation lines. This has the 
byproduct of possibly converting pre-existing FWS in a header, as 
evidenced by mailman 2.1.6 which exposes the problem.

If the Header class is passed pre-existing Header lines, which in the 
mailman case is from the original message, and, without any 
manipulation, ask it for the encoded version, it replaces the original 
folding with the continuation_ws characters.

Given that RFC 2822 unfolding consists only of removing CRLFs, 
exchanging out the FWS characters changes the logical content of a 
header value. Standard folding of us-ascii text should only consist of 
introducing line breaks in front of original FWS in the header line. In 
the case where the encoding of the source string requires multiple 
adjacent RFC 2047 encoded-words (either due to disparate encodings 
or text length), then FWS can be freely inserted and is treated as an 
artifact of the encoding. It is ignored on reading and as such it doesn't 
affect the logical content of the header value. It's in this latter case that 
the continuation_ws parameter should be used.

e.g., 

#!/usr/bin/python -d
from email.Header import Header
s = "Thread-Topic: Use of tabs when folding header lines -- increasing 
subject\n length as a test\n"
print Header(s, 'us-ascii', None, None, '\t')

This script will have replaced the space in front of the word "length" 
with a tab. It should retain that space and not convert it to the 
continuation_ws character.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1372770&group_id=5470


More information about the Python-bugs-list mailing list