diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php
index df2d2b09ee6..c4c8026e076 100644
--- a/htdocs/admin/security.php
+++ b/htdocs/admin/security.php
@@ -170,9 +170,23 @@ elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK')
if ($action == 'maj_pattern')
{
- dolibarr_set_const($db, "USER_PASSWORD_PATTERN", GETPOST("pattern"), 'chaine', 0, '', $conf->entity);
- header("Location: security.php");
- exit;
+ $pattern = GETPOST("pattern");
+ $explodePattern = explode(';', $pattern);
+
+ $patternInError = false;
+ if($explodePattern[0] < 1 || $explodePattern[4] < 1){
+ $patternInError = true;
+ }
+
+ if($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]){
+ $patternInError = true;
+ }
+
+ if(!$patternInError){
+ dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity);
+ header("Location: security.php");
+ exit;
+ }
}
@@ -278,13 +292,6 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){
$tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN);
- /*$this->length2 = $tabConf[0];
- $this->NbMaj = $tabConf[1];
- $this->NbNum = $tabConf[2];
- $this->NbSpe = $tabConf[3];
- $this->NbRepeat = $tabConf[4];
- $this->WithoutAmbi = $tabConf[5];
- */
print '
';
print '