mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-02 19:01:03 +01: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:
parent
492d047a49
commit
b571f0b229
1 changed files with 14 additions and 3 deletions
|
@ -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.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue