Added upper limit for user and tag length
This commit is contained in:
parent
019ce6a141
commit
65df7f8752
3 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,7 @@ staffActivation = 0
|
|||
passMinLength = 5
|
||||
passRegex = "/^.+$/"
|
||||
userNameMinLength = 3
|
||||
userNameMaxLength = 20
|
||||
userNameRegex = "/^[\w_-]+$/ui"
|
||||
salt = "1A2/$_4xVa"
|
||||
|
||||
|
|
|
@ -32,6 +32,13 @@ class Model_Post extends RedBean_SimpleModel
|
|||
{
|
||||
$tag = trim($tag);
|
||||
|
||||
$minLength = 1;
|
||||
$maxLength = 64;
|
||||
if (strlen($tag) < $minLength)
|
||||
throw new SimpleException('Tag must have at least ' . $minLength . ' characters');
|
||||
if (strlen($tag) > $maxLength)
|
||||
throw new SimpleException('Tag must have at most ' . $maxLength . ' characters');
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9_-]+$/i', $tag))
|
||||
throw new SimpleException('Invalid tag "' . $tag . '"');
|
||||
|
||||
|
|
|
@ -77,11 +77,15 @@ class Model_User extends RedBean_SimpleModel
|
|||
}
|
||||
|
||||
$userNameMinLength = intval(\Chibi\Registry::getConfig()->registration->userNameMinLength);
|
||||
$userNameMaxLength = intval(\Chibi\Registry::getConfig()->registration->userNameMaxLength);
|
||||
$userNameRegex = \Chibi\Registry::getConfig()->registration->userNameRegex;
|
||||
|
||||
if (strlen($userName) < $userNameMinLength)
|
||||
throw new SimpleException(sprintf('User name must have at least %d characters', $userNameMinLength));
|
||||
|
||||
if (strlen($userName) > $userNameMaxLength)
|
||||
throw new SimpleException(sprintf('User name must have at most %d characters', $userNameMaxLength));
|
||||
|
||||
if (!preg_match($userNameRegex, $userName))
|
||||
throw new SimpleException('User name contains invalid characters');
|
||||
|
||||
|
|
Loading…
Reference in a new issue