From fc2490c2e7170a0d41d6d9eb6c8f36e488a93fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 18 Aug 2024 22:03:38 +0200 Subject: [PATCH] Verify the length of an internal note when banning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/RoomInfoTableViewController.m | 31 +++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/NextcloudTalk/RoomInfoTableViewController.m b/NextcloudTalk/RoomInfoTableViewController.m index f6c7b0a31..763faf80e 100644 --- a/NextcloudTalk/RoomInfoTableViewController.m +++ b/NextcloudTalk/RoomInfoTableViewController.m @@ -134,6 +134,10 @@ @interface RoomInfoTableViewController () textField.text.length) { return NO; } + // Set maximum character length NSUInteger newLength = [textField.text length] + [string length] - range.length; - BOOL hasAllowedLength = newLength <= 200; - // Enable/Disable password confirmation button - if (hasAllowedLength) { + + NSUInteger allowedLength = 200; + + if (textField == _banInternalNoteTextField) { + allowedLength = 4000; + } + + BOOL hasAllowedLength = newLength <= allowedLength; + + // An internal note on banning is optional, so only enable/disable password confirmation button + if (hasAllowedLength && textField == _setPasswordTextField) { NSString *newValue = [[textField.text stringByReplacingCharactersInRange:range withString:string] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; _setPasswordAction.enabled = (newValue.length > 0); } + return hasAllowedLength; }