diff --git a/cgi-bin/webnotes/utils/__init__.py b/cgi-bin/webnotes/utils/__init__.py index 80f7f5af1a..22c854faf1 100644 --- a/cgi-bin/webnotes/utils/__init__.py +++ b/cgi-bin/webnotes/utils/__init__.py @@ -22,14 +22,21 @@ def getCSVelement(v): return '"'+v+'"' else: return v or '' -def validate_email_add(email_str): +def extract_email_id(s): """ - Validates the email string + Extract email id from email header format """ - s = email_str if '<' in s: s = s.split('<')[1].split('>')[0] - if s: s = s.strip().lower() + if s: + s = s.strip().lower() + return s + +def validate_email_add(email_str): + """ + Validates the email string + """ + s = extract_email_id(email_str) import re #return re.match("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email_str) return re.match("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", s)