[issue10574] email.header.decode_header fails if the string contains multiple directives

Roy Hyunjin Han report at bugs.python.org
Mon Nov 29 06:12:29 CET 2010

Roy Hyunjin Han <starsareblueandfaraway at gmail.com> added the comment:

Currently using the following workaround.

import re
import email.header

def decodeSafely(x):
    match = re.search('(=\?.*?\?B\?)', x)
    if not match:
        return x
    encoding = match.group(1)
    return email.header.decode_header('%s%s==?=' % (encoding, x.replace(encoding, '').replace('?', '').replace('=', '')))


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list