Only decode when necessary.

fix #545
This commit is contained in:
Antoine Nguyen
2014-05-01 15:41:07 +02:00
parent a9d5c68b21
commit 1ab2e31fe6
@@ -85,7 +85,9 @@ def create_mail_attachment(attdef, payload=None):
else:
res.set_payload(payload)
Encoders.encode_base64(res)
res['Content-Disposition'] = build_header(attdef['fname'].decode('utf-8'))
if type(attdef['fname']) is str:
attdef['fname'] = attdef['fname'].decode('utf-8')
res['Content-Disposition'] = build_header(attdef['fname'])
return res