Merge branch 'master' into develop

This commit is contained in:
Saurabh 2019-03-20 14:30:48 +05:30
commit 6d9fa54f0b
4 changed files with 27 additions and 9 deletions

View file

@ -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()

View file

@ -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 = ''

View file

@ -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('<span>This is string</span>' 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)]

View file

@ -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',