@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+7 -3
+5 -3
src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php
··· 72 72 // problems. 73 73 74 74 foreach ($xactions as $xaction) { 75 - $new = $xaction->getNewValue(); 76 - if (!strlen($new)) { 75 + $new_value = $xaction->getNewValue(); 76 + $new_value = trim($new_value); // Strip surrounding whitespace 77 + $xaction->setNewValue($new_value); 78 + if (!strlen($new_value)) { 77 79 $errors[] = $this->newInvalidError( 78 80 pht('Tasks must have a title.'), 79 81 $xaction); 80 82 continue; 81 83 } 82 - if (mb_strlen($new) > $this->maximumTaskTitleLength) { 84 + if (mb_strlen($new_value) > $this->maximumTaskTitleLength) { 83 85 $errors[] = $this->newInvalidError( 84 86 pht('Task title cannot exceed %d characters.', 85 87 $this->maximumTaskTitleLength),
+2
src/applications/project/xaction/PhabricatorProjectNameTransaction.php
··· 72 72 $max_length = $object->getColumnMaximumByteLength('name'); 73 73 foreach ($xactions as $xaction) { 74 74 $new_value = $xaction->getNewValue(); 75 + $new_value = trim($new_value); // Strip surrounding whitespace 76 + $xaction->setNewValue($new_value); 75 77 $new_length = strlen($new_value); 76 78 if ($new_length > $max_length) { 77 79 $errors[] = $this->newInvalidError(