From 9219db4c2a4dbb0709cc0f893622262cc4defc2e Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 16 Oct 2020 14:09:35 +0530 Subject: [PATCH 1/3] fix: validate email id before passing to formataddr --- frappe/utils/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index d3bf1dd10c..9640bcd394 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -66,9 +66,14 @@ def get_email_address(user=None): def get_formatted_email(user, mail=None): """get Email Address of user formatted as: `John Doe `""" fullname = get_fullname(user) + if not mail: - mail = get_email_address(user) - return cstr(make_header(decode_header(formataddr((fullname, mail))))) + mail = get_email_address(user) or validate_email_address(user) + + if not mail: + return '' + else: + return cstr(make_header(decode_header(formataddr((fullname, mail))))) def extract_email_id(email): """fetch only the email part of the Email Address""" From 9d060f96533679b7f9fa187e63ae548a73f4258f Mon Sep 17 00:00:00 2001 From: Abhishek Balam Date: Fri, 4 Dec 2020 17:01:55 +0530 Subject: [PATCH 2/3] fix: cstr import added --- frappe/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index 9640bcd394..d76e6c951e 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -10,7 +10,7 @@ import functools from .html_utils import sanitize_html import frappe from frappe.utils.identicon import Identicon -from email.utils import parseaddr, formataddr +from email.utils import parseaddr, formataddr, cstr from email.header import decode_header, make_header # utility functions like cint, int, flt, etc. from frappe.utils.data import * From d229e363b39d26a0ff11ee4efb2ed2693da6c158 Mon Sep 17 00:00:00 2001 From: Abhishek Balam Date: Fri, 4 Dec 2020 17:10:42 +0530 Subject: [PATCH 3/3] fix: revert cstr import added --- frappe/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index d76e6c951e..9640bcd394 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -10,7 +10,7 @@ import functools from .html_utils import sanitize_html import frappe from frappe.utils.identicon import Identicon -from email.utils import parseaddr, formataddr, cstr +from email.utils import parseaddr, formataddr from email.header import decode_header, make_header # utility functions like cint, int, flt, etc. from frappe.utils.data import *