From 63d69be18a6a38aab20a61bb47fc1bed49620a68 Mon Sep 17 00:00:00 2001 From: Andrew Fyfe Date: Thu, 25 Jan 2018 04:27:43 +0000 Subject: [PATCH] parse lists of e-mail recipients properly A comma (,) is a valid separator in accordance with RFC 2822, it was Microsoft Outlook that introduced the use of semicolon (;). getaddresses() will correctly split a string containing multiple e-mail addresses separated by a comma or semicolon. closes #121 --- modoboa_webmail/static/modoboa_webmail/js/webmail.js | 2 +- modoboa_webmail/validators.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modoboa_webmail/static/modoboa_webmail/js/webmail.js b/modoboa_webmail/static/modoboa_webmail/js/webmail.js index b31b5e4..ab5b71d 100644 --- a/modoboa_webmail/static/modoboa_webmail/js/webmail.js +++ b/modoboa_webmail/static/modoboa_webmail/js/webmail.js @@ -1140,7 +1140,7 @@ Webmail.prototype = { this.page_update(resp); if (this.options.contactListUrl) { this.$select = $('.selectize-contact').selectize({ - delimiter: ';', + delimiter: ',', valueField: 'address', searchField: 'address', options: [], diff --git a/modoboa_webmail/validators.py b/modoboa_webmail/validators.py index a11fbe0..217c932 100644 --- a/modoboa_webmail/validators.py +++ b/modoboa_webmail/validators.py @@ -8,12 +8,11 @@ class EmailListValidator(object): - """Validate a semi-comma separated list of email.""" + """Validate a list of email.""" def __call__(self, value): value = force_text(value) - emails = [email.strip() for email in value.split(";")] - addresses = getaddresses(emails) + addresses = getaddresses([value]) [validate_email(email) for name, email in addresses]