Browse Source

Fixed quota regex

Sergio Brighenti 5 years ago
parent
commit
ce497f9728
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/Controllers/UserController.php

+ 2 - 2
app/Controllers/UserController.php

@@ -73,7 +73,7 @@ class UserController extends Controller
         $validator = $this->getUserCreateValidator($request)
             ->callIf($this->getSetting('quota_enabled') === 'on', function ($session) use (&$maxUserQuota, &$request) {
                 $maxUserQuota = param($request, 'max_user_quota', humanFileSize($this->getSetting('default_user_quota'), 0, true));
-                if (!preg_match('/([0-9]+[K|M|G|T])|(\-1)/i', $maxUserQuota)) {
+                if (!preg_match('/(^[0-9]+[B|K|M|G|T]$)|(^\-1$)/i', $maxUserQuota)) {
                     $session->alert(lang('invalid_quota', 'danger'));
                     return false;
                 }
@@ -163,7 +163,7 @@ class UserController extends Controller
             ->alertIf($user->id === $this->session->get('user_id') && param($request, 'is_admin') === null, 'cannot_demote')
             ->callIf($this->getSetting('quota_enabled') === 'on', function ($session) use (&$user, &$request) {
                 $maxUserQuota = param($request, 'max_user_quota', humanFileSize($this->getSetting('default_user_quota'), 0, true));
-                if (!preg_match('/([0-9]+[K|M|G|T])|(\-1)/i', $maxUserQuota)) {
+                if (!preg_match('/(^[0-9]+[B|K|M|G|T]$)|(^\-1$)/i', $maxUserQuota)) {
                     $session->alert(lang('invalid_quota', 'danger'));
                     return false;
                 }