Strip surrounding whitespace from project and task titles
Summary: When creating or renaming a project or a task, copy and paste can lead to unwanted whitespace. Thus strip any whitespace from the beginning and end of the title string by using `trim()` when running `validateTransactions()`. Test Plan: * Create and rename projects and tasks with whitespace at the beginning and the end of their names. Confirm that the whitespace gets removed. Get correctly sorted database query search results, don't get notification mail saying `Foo added a parent task: Txxxx: Title .` anymore which annoys pedants like me. * Create and rename projects and tasks by setting the title to include whitespace only. Confirm that the error about being empty is shown. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Tags: #maniphest, #projects Differential Revision: https://we.phorge.it/D25835
This commit is contained in:
parent
1d27fde018
commit
ff6a998f23
|
@ -72,14 +72,16 @@ final class ManiphestTaskTitleTransaction
|
|||
// problems.
|
||||
|
||||
foreach ($xactions as $xaction) {
|
||||
$new = $xaction->getNewValue();
|
||||
if (!strlen($new)) {
|
||||
$new_value = $xaction->getNewValue();
|
||||
$new_value = trim($new_value); // Strip surrounding whitespace
|
||||
$xaction->setNewValue($new_value);
|
||||
if (!strlen($new_value)) {
|
||||
$errors[] = $this->newInvalidError(
|
||||
pht('Tasks must have a title.'),
|
||||
$xaction);
|
||||
continue;
|
||||
}
|
||||
if (mb_strlen($new) > $this->maximumTaskTitleLength) {
|
||||
if (mb_strlen($new_value) > $this->maximumTaskTitleLength) {
|
||||
$errors[] = $this->newInvalidError(
|
||||
pht('Task title cannot exceed %d characters.',
|
||||
$this->maximumTaskTitleLength),
|
||||
|
|
|
@ -72,6 +72,8 @@ final class PhabricatorProjectNameTransaction
|
|||
$max_length = $object->getColumnMaximumByteLength('name');
|
||||
foreach ($xactions as $xaction) {
|
||||
$new_value = $xaction->getNewValue();
|
||||
$new_value = trim($new_value); // Strip surrounding whitespace
|
||||
$xaction->setNewValue($new_value);
|
||||
$new_length = strlen($new_value);
|
||||
if ($new_length > $max_length) {
|
||||
$errors[] = $this->newInvalidError(
|
||||
|
|
Loading…
Reference in a new issue