classification
Title: email.header unicode fix
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, tkikuchi (2)
Priority: normal Keywords easy, patch

Created on 2007-03-15 11:13 by tkikuchi, last changed 2009-04-22 05:08 by ajaksu2.

Files
File name Uploaded Description Edit Remove
email_header_unicode.patch tkikuchi, 2007-03-16 02:01 email_header_unicode.patch
Messages (2)
msg52236 - (view) Author: Tokio Kikuchi (tkikuchi) Date: 2007-03-15 11:13
email.header.Header class has its unicode representation which is slightly different from str representation.

>>> h = email.Header.make_header((('[XXX]', 'us-ascii'), ('Re:', 'us-ascii')))
>>> unicode(h)
u'[XXX]Re:'
>>> str(h)
'[XXX] Re:'

Note that a white space between ']' and 'R' is absent from unicode representation.  A word-separating space should be needed in following contexts:

lastcs \ nextcs | ascii | other |
     ascii      |  sp   |   sp  |
     other      |  sp   | nosp  |

Current code fails to put a space for ascii\ascii case.

Also, if the ascii string has a trailing space, it may result in a extraneous double space which has semantically equivalent to a single space and sometimes annoying.  You should use qp encoding for ascii charset if you insist on the presence of the space.

The patch includes test code. :)
msg52237 - (view) Author: Tokio Kikuchi (tkikuchi) Date: 2007-03-16 02:01
Sorry but I am withdrawing the latter part of the patch for ascii encoding.  Revised patch is for only unicode representation.

File Added: email_header_unicode.patch
History
Date User Action Args
2009-04-22 05:08:27ajaksu2setkeywords: + easy
2009-03-30 22:58:29ajaksu2setstage: patch review
type: behavior
versions: + Python 2.6, - Python 2.5
2009-03-30 22:56:23ajaksu2linkissue1685453 dependencies
2007-03-15 11:13:52tkikuchicreate