From 0339bc3ec9d0430c29db77e28233ee3226824590 Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 6 Jun 2022 17:10:11 +0200 Subject: [PATCH] Removed special case from about page length limit. --- public/profile.php | 2 +- src/Users/User.php | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/public/profile.php b/public/profile.php index a2b43ca4..142882c1 100644 --- a/public/profile.php +++ b/public/profile.php @@ -96,7 +96,7 @@ if($isEditing) { } else { $aboutText = (string)($_POST['about']['text'] ?? ''); $aboutParse = (int)($_POST['about']['parser'] ?? Parser::PLAIN); - $aboutValid = User::validateProfileAbout($aboutParse, $aboutText, strlen($profileUser->getProfileAboutText()) > User::PROFILE_ABOUT_MAX_LENGTH); + $aboutValid = User::validateProfileAbout($aboutParse, $aboutText); if($aboutValid === '') $currentUser->setProfileAboutText($aboutText)->setProfileAboutParser($aboutParse); diff --git a/src/Users/User.php b/src/Users/User.php index 43f784b3..5d32e21a 100644 --- a/src/Users/User.php +++ b/src/Users/User.php @@ -40,21 +40,11 @@ class User implements HasRankInterface, JsonSerializable { public const PASSWORD_ALGO = PASSWORD_ARGON2ID; // Maximum length of profile about section - public const PROFILE_ABOUT_MAX_LENGTH = 60000; - public const PROFILE_ABOUT_MAX_LENGTH_OLD = 65535; // Used for malloc's essay + public const PROFILE_ABOUT_MAX_LENGTH = 50000; // Maximum length of forum signature public const FORUM_SIGNATURE_MAX_LENGTH = 2000; - // Order constants for ::all function - public const ORDER_ID = 'id'; - public const ORDER_NAME = 'name'; - public const ORDER_COUNTRY = 'country'; - public const ORDER_CREATED = 'registered'; - public const ORDER_ACTIVE = 'last-online'; - public const ORDER_FORUM_TOPICS = 'forum-topics'; - public const ORDER_FORUM_POSTS = 'forum-posts'; - // Database fields private $user_id = -1; private $username = ''; @@ -699,12 +689,12 @@ class User implements HasRankInterface, JsonSerializable { return ''; } - public static function validateProfileAbout(int $parser, string $text, bool $useOld = false): string { + public static function validateProfileAbout(int $parser, string $text): string { if(!Parser::isValid($parser)) return 'parser'; $length = strlen($text); - if($length > ($useOld ? self::PROFILE_ABOUT_MAX_LENGTH_OLD : self::PROFILE_ABOUT_MAX_LENGTH)) + if($length > self::PROFILE_ABOUT_MAX_LENGTH) return 'long'; return '';