diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
index aedc870560fc1f3e6546f001cd7ef7461be31151..7440a357ea8f669330120a2d48e691552140c1a6 100644
--- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
+++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
@@ -90,11 +90,12 @@ class modGeneratePassPerso extends ModeleGenPassword
 		$this->NbRepeat = $tabConf[4];
 		$this->WithoutAmbi = $tabConf[5];
 
-		if($this->WithoutAmbi){
-			$this->Maj = str_replace($this->Ambi,"",$this->Maj );
-			$this->Min = str_replace($this->Ambi,"",$this->Min );
-			$this->Nb  = str_replace($this->Ambi,"",$this->Nb  );
-			$this->Spe = str_replace($this->Ambi,"",$this->Spe );
+		if ($this->WithoutAmbi)
+		{
+			$this->Maj = str_replace($this->Ambi,"",$this->Maj);
+			$this->Min = str_replace($this->Ambi,"",$this->Min);
+			$this->Nb  = str_replace($this->Ambi,"",$this->Nb);
+			$this->Spe = str_replace($this->Ambi,"",$this->Spe);
 		}
 
 		$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe);
@@ -148,11 +149,13 @@ class modGeneratePassPerso extends ModeleGenPassword
 			$pass .= $this->All[rand(0,strlen($this->All) -1)];
 		}
 
-		$pass = str_shuffle($pass) ;
+		$pass = str_shuffle($pass);
 
-		if($this->validatePassword($pass)) {
+		if ($this->validatePassword($pass))
+		{
 			return $pass;
 		}
+
 		return $this->getNewGeneratedPassword();
 	}