From 6bd511346f57454dab18c8b7eea115de3e8eb7b3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 12:24:05 +0530 Subject: [PATCH] fix in decode email header, used while receiving email - for decoding encoded headers --- py/webnotes/utils/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/py/webnotes/utils/__init__.py b/py/webnotes/utils/__init__.py index 6738d4e21e..f3cb3b71ef 100644 --- a/py/webnotes/utils/__init__.py +++ b/py/webnotes/utils/__init__.py @@ -63,12 +63,10 @@ def decode_email_header(s): # double quotes in header prohibit decoding of header decoded_header_tuple = email.header.decode_header(s.replace('"', '')) - decoded_list = [] - for header in decoded_header_tuple: - decoded_list.append(cstr(header[0], encoding = header[1] or 'utf-8')) - + decoded_list = map(lambda h: unicode(h[0], encoding=h[1] or 'utf-8'), decoded_header_tuple) + return " ".join(decoded_list) - + def extract_email_id(s): """ Extract email id from email header format