diff --git a/doc/conf/LSattribute/check_data/password.docbook b/doc/conf/LSattribute/check_data/password.docbook
index cffccf1a..51b1c649 100644
--- a/doc/conf/LSattribute/check_data/password.docbook
+++ b/doc/conf/LSattribute/check_data/password.docbook
@@ -31,11 +31,23 @@
regex
Expression(s) régulière(s) que doit respecter le mot de passe. Ce
- paramètre peut être une expression régulière ou un tableau d'expressions
- régulières.
+ paramètre peut être une expression régulière au format
+ PCRE ou un tableau
+ d'expressions régulières.
+
+ minValidRegex
+
+ Le nombre minimum d'expression régulière qui doivent être validées
+ pour que le mot de passe soit considéré comme correct. Ce paramètre est
+ optionnel, par défaut, toutes les expressions régulières doivent être
+ validées.
+
+
+
+
diff --git a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
index 96ce0304..0bd81f17 100644
--- a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
+++ b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
@@ -513,7 +513,14 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'msg' => 'Your password must contain from 8 to 10 characters.',
'params' => array(
'minLength' => 8,
- 'maxLength' => 10
+ 'maxLength' => 10,
+ 'regex' => array (
+ '/[A-Z]/',
+ '/[a-z]/',
+ '/[0-9]/',
+ '/[^A-Za-z0-9]/',
+ ),
+ 'minValidRegex' => 3
)
)
),
diff --git a/public_html/includes/class/class.LSformRule_password.php b/public_html/includes/class/class.LSformRule_password.php
index 501792e6..00791345 100644
--- a/public_html/includes/class/class.LSformRule_password.php
+++ b/public_html/includes/class/class.LSformRule_password.php
@@ -37,6 +37,8 @@ class LSformRule_password extends LSformRule {
* - 'prohibitedValues' : Un tableau de valeurs interdites
* - 'regex' : une ou plusieurs expressions régulières
* devant matche
+ * - 'minValidRegex' : le nombre minimun d'expressions
+ * régulières à valider
* @param object $formElement L'objet formElement attaché
*
* @return boolean true si la valeur est valide, false sinon
@@ -56,14 +58,30 @@ class LSformRule_password extends LSformRule {
if (!is_array($options['params']['regex'])) {
$options['params']['regex']=array($options['params']['regex']);
}
- foreach($options['params']['regex'] as $regex) {
- if (!ereg($regex,$value))
- return;
+ if (isset($options['params']['minValidRegex'])) {
+ $options['params']['minValidRegex']=(int)$options['params']['minValidRegex'];
+ if ($options['params']['minValidRegex']==0 || $options['params']['minValidRegex']>count($options['params']['regex'])) {
+ $options['params']['minValidRegex']=count($options['params']['regex']);
+ }
}
+ else {
+ $options['params']['minValidRegex']=count($options['params']['regex']);
+ }
+ $valid=0;
+ foreach($options['params']['regex'] as $regex) {
+ if ($regex[0]!='/') {
+ LSerror :: addErrorCode('LSformRule_password_01');
+ continue;
+ }
+ if (preg_match($regex,$value))
+ $valid++;
+ }
+ if ($valid<$options['params']['minValidRegex'])
+ return;
}
-
- if(is_array($options['params']['prohibitedValues'])) {
- if (in_array($value,$options['params']['prohibitedValues']))
+
+ if(isset($options['params']['prohibitedValues']) && is_array($options['params']['prohibitedValues'])) {
+ if (in_array($value,$options['params']['prohibitedValues']))
return;
}
@@ -72,4 +90,11 @@ class LSformRule_password extends LSformRule {
}
+
+/*
+ * Error Codes
+ */
+LSerror :: defineError('LSformRule_password_01',
+_("LSformRule_password : Invalid regex configured : %{regex}. You must use PCRE (begining by '/' caracter).")
+);
?>