Fixes #2002. Trailing comma in Liaison cc_contacts field causes invalid email address error. Commit ready for merge.

- Legacy-Id: 13292
This commit is contained in:
Ryan Cross 2017-05-09 23:28:35 +00:00
parent 9a9531d9f6
commit 9972a5464a

View file

@ -102,6 +102,7 @@ def validate_emails(value):
value = value.strip() # strip whitespace
if '\r\n' in value: # cc_contacts has newlines
value = value.replace('\r\n',',')
value = value.rstrip(',') # strip trailing comma
emails = value.split(',')
for email in emails:
name, addr = parseaddr(email)
@ -277,7 +278,9 @@ class LiaisonModelForm(BetterModelForm):
def clean_cc_contacts(self):
'''Return a comma separated list of addresses'''
cc_contacts = self.cleaned_data.get('cc_contacts')
return cc_contacts.replace('\r\n',',')
cc_contacts = cc_contacts.replace('\r\n',',')
cc_contacts = cc_contacts.rstrip(',')
return cc_contacts
def clean(self):
if not self.cleaned_data.get('body', None) and not self.has_attachments():