From 62aaa0fcbef5fb0c4aaf22de78dc0813585c3804 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 1 Aug 2024 16:55:37 +0200 Subject: [PATCH] Restrict maximum task title length to 255 characters Summary: A task title is supposed to summarize a task. For long novels, there is the task description. Closes T15898 Test Plan: Go to http://phorge.localhost/maniphest/task/edit/form/default/ and enter a task title with multi-byte characters above the threshold, press "Enter". Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15898 Differential Revision: https://we.phorge.it/D25759 --- .../maniphest/xaction/ManiphestTaskTitleTransaction.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php index c01c263ba6..bef8914cf7 100644 --- a/src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php +++ b/src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php @@ -4,6 +4,7 @@ final class ManiphestTaskTitleTransaction extends ManiphestTaskTransactionType { const TRANSACTIONTYPE = 'title'; + private $maximumTaskTitleLength = 255; public function generateOldValue($object) { return $object->getTitle(); @@ -78,6 +79,13 @@ final class ManiphestTaskTitleTransaction $xaction); continue; } + if (mb_strlen($new) > $this->maximumTaskTitleLength) { + $errors[] = $this->newInvalidError( + pht('Task title cannot exceed %d characters.', + $this->maximumTaskTitleLength), + $xaction); + continue; + } } if (!$errors) { -- 2.51.2