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->setURI($request->getStr('uri'));
$e_email = null;
$e_name = null;
if (!strlen($list->getEmail())) {
$e_email = 'Required';
$errors[] = 'Email is required.';
@@ -55,6 +58,9 @@ class PhabricatorMetaMTAMailingListEditController
if (!strlen($list->getName())) {
$e_name = '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()) {
@@ -65,9 +71,14 @@ class PhabricatorMetaMTAMailingListEditController
}
if (!$errors) {
$list->save();
return id(new AphrontRedirectResponse())
->setURI('/mail/lists/');
try {
$list->save();
return id(new AphrontRedirectResponse())
->setURI('/mail/lists/');
} catch (AphrontQueryDuplicateKeyException $ex) {
$e_email = 'Duplicate';
$errors[] = 'Another mailing list already uses that address.';
}
}
}