1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 17:28:51 +02:00

Forbid mailing list names contianing spaces or commas

Summary:
They end up in "CCs:" fields where they can't be parsed.

Not bothering to migrate since I think only Dropbox has hit this.

Also improved another error condition's handling.

Test Plan: Tried to save a mailing list with spaces and commas in the name.

Reviewers: btrahan, Makinde

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T947

Differential Revision: https://secure.phabricator.com/D1813
This commit is contained in:
epriestley 2012-03-07 13:18:00 -08:00
parent 492d047a49
commit b571f0b229

View file

@ -47,6 +47,9 @@ class PhabricatorMetaMTAMailingListEditController
$list->setEmail($request->getStr('email')); $list->setEmail($request->getStr('email'));
$list->setURI($request->getStr('uri')); $list->setURI($request->getStr('uri'));
$e_email = null;
$e_name = null;
if (!strlen($list->getEmail())) { if (!strlen($list->getEmail())) {
$e_email = 'Required'; $e_email = 'Required';
$errors[] = 'Email is required.'; $errors[] = 'Email is required.';
@ -55,6 +58,9 @@ class PhabricatorMetaMTAMailingListEditController
if (!strlen($list->getName())) { if (!strlen($list->getName())) {
$e_name = 'Required'; $e_name = 'Required';
$errors[] = 'Name is required.'; $errors[] = 'Name is required.';
} else if (preg_match('/[ ,]/', $list->getName())) {
$e_name = 'Invalid';
$errors[] = 'Name must not contain spaces or commas.';
} }
if ($list->getURI()) { if ($list->getURI()) {
@ -65,9 +71,14 @@ class PhabricatorMetaMTAMailingListEditController
} }
if (!$errors) { if (!$errors) {
$list->save(); try {
return id(new AphrontRedirectResponse()) $list->save();
->setURI('/mail/lists/'); return id(new AphrontRedirectResponse())
->setURI('/mail/lists/');
} catch (AphrontQueryDuplicateKeyException $ex) {
$e_email = 'Duplicate';
$errors[] = 'Another mailing list already uses that address.';
}
} }
} }