diff --git a/frappe/__init__.py b/frappe/__init__.py index d01d77e044..0aae4408c5 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -24,7 +24,7 @@ if sys.version[0] == '2': reload(sys) sys.setdefaultencoding("utf-8") -__version__ = '11.1.14' +__version__ = '11.1.15' __title__ = "Frappe Framework" local = Local() diff --git a/frappe/email/receive.py b/frappe/email/receive.py index 09aa4ff57a..dcd21d3c10 100644 --- a/frappe/email/receive.py +++ b/frappe/email/receive.py @@ -357,9 +357,13 @@ class Email: """Parses headers, content, attachments from given raw message. :param content: Raw message.""" - self.raw = safe_encode(content) if six.PY2 else safe_decode(content) - self.mail = email.message_from_string(self.raw) - + if six.PY2: + self.mail = email.message_from_string(safe_encode(content)) + else: + if isinstance(content, bytes): + self.mail = email.message_from_bytes(content) + else: + self.mail = email.message_from_string(content) self.text_content = '' self.html_content = '' diff --git a/frappe/email/test_email_body.py b/frappe/email/test_email_body.py index b0bfddd4f0..feb8e80007 100644 --- a/frappe/email/test_email_body.py +++ b/frappe/email/test_email_body.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import unittest, os, base64 +from frappe.email.receive import Email from frappe.email.email_body import (replace_filename_with_cid, get_email, inline_style_in_html, get_header) @@ -136,6 +137,20 @@ d85b; border-radius:8px; display:inline-block; height:8px; margin-right:5px= html = get_header('This is string') self.assertTrue('This is string' in html) + def test_8bit_utf_8_decoding(self): + text_content_bytes = b"\xed\x95\x9c\xea\xb8\x80\xe1\xa5\xa1\xe2\x95\xa5\xe0\xba\xaa\xe0\xa4\x8f" + text_content = text_content_bytes.decode('utf-8') + + content_bytes = b"""MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +From: test1_@erpnext.com +Reply-To: test2_@erpnext.com +""" + text_content_bytes + + mail = Email(content_bytes) + self.assertEqual(mail.text_content, text_content) def fixed_column_width(string, chunk_size): parts = [string[0+i:chunk_size+i] for i in range(0, len(string), chunk_size)] diff --git a/frappe/utils/user.py b/frappe/utils/user.py index cd8cb35146..c29393fc31 100755 --- a/frappe/utils/user.py +++ b/frappe/utils/user.py @@ -276,11 +276,6 @@ def add_system_manager(email, first_name=None, last_name=None, send_welcome_emai "send_welcome_email": 1 if send_welcome_email else 0 }) - if password: - user.update({ - "new_password": password - }) - user.insert() # add roles @@ -293,6 +288,10 @@ def add_system_manager(email, first_name=None, last_name=None, send_welcome_emai roles = [role.name for role in roles] user.add_roles(*roles) + if password: + from frappe.utils.password import update_password + update_password(user=user.name, pwd=password) + def get_enabled_system_users(): # add more fields if required return frappe.get_all('User',