Added more email validation for draft submission author emails, and blocked some baths that could lead to bad email addresses ('none') being set as document author email addresses.
- Legacy-Id: 13010
This commit is contained in:
parent
888aa75a2f
commit
bb5096da8a
|
@ -23,8 +23,9 @@ from ietf.person.models import Person, Email
|
|||
from ietf.community.utils import update_name_contains_indexes_with_new_doc
|
||||
from ietf.submit.mail import announce_to_lists, announce_new_version, announce_to_authors
|
||||
from ietf.submit.models import Submission, SubmissionEvent, Preapproval, DraftSubmissionStateName
|
||||
from ietf.utils import unaccent
|
||||
from ietf.utils import log
|
||||
from ietf.utils import unaccent
|
||||
from ietf.utils.mail import is_valid_email
|
||||
|
||||
|
||||
def validate_submission(submission):
|
||||
|
@ -373,20 +374,20 @@ def update_replaces_from_submission(request, submission, draft):
|
|||
|
||||
def get_person_from_name_email(name, email):
|
||||
# try email
|
||||
if email:
|
||||
if email and (email.startswith('unknown-email-') or is_valid_email(email)):
|
||||
persons = Person.objects.filter(email__address=email).distinct()
|
||||
if len(persons) == 1:
|
||||
return persons[0]
|
||||
else:
|
||||
persons = Person.objects.none()
|
||||
|
||||
if not persons:
|
||||
if not persons.exists():
|
||||
persons = Person.objects.all()
|
||||
|
||||
# try full name
|
||||
p = persons.filter(alias__name=name).distinct()
|
||||
if p:
|
||||
return p[0]
|
||||
if p.exists():
|
||||
return p.first()
|
||||
|
||||
return None
|
||||
|
||||
|
@ -406,7 +407,7 @@ def ensure_person_email_info_exists(name, email):
|
|||
person.save()
|
||||
|
||||
# make sure we have an email address
|
||||
if addr:
|
||||
if addr and (addr.startswith('unknown-email-') or is_valid_email(addr)):
|
||||
active = True
|
||||
addr = addr.lower()
|
||||
else:
|
||||
|
|
|
@ -18,7 +18,8 @@ from email import charset as Charset
|
|||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
||||
from django.core.validators import validate_email
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import Context,RequestContext
|
||||
|
||||
|
@ -438,3 +439,9 @@ def send_error_to_secretariat(msg):
|
|||
(extype,value) = sys.exc_info()[:2]
|
||||
log("SMTP Exception: %s : %s" % (extype,value))
|
||||
|
||||
def is_valid_email(address):
|
||||
try:
|
||||
validate_email(address)
|
||||
return True
|
||||
except ValidationError:
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue