Merge pull request #19737 from aspangaro/16a6

NEW Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad character unauthorized into login name
This commit is contained in:
Laurent Destailleur 2022-01-25 16:04:11 +01:00 committed by GitHub
commit 34e930d952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1397,6 +1397,8 @@ class User extends CommonObject
dol_syslog(get_class($this)."::create login=".$this->login.", user=".(is_object($user) ? $user->id : ''), LOG_DEBUG);
$badCharUnauthorizedIntoLoginName = getDolGlobalString('MAIN_LOGIN_BADCHARUNAUTHORIZED', ',@<>"\'');
// Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
@ -1407,7 +1409,7 @@ class User extends CommonObject
$langs->load("errors");
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
return -1;
} elseif (preg_match('/[,@<>"\']/', $this->login)) {
} elseif (preg_match('/['.preg_quote($badCharUnauthorizedIntoLoginName, '/').']/', $this->login)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadCharIntoLoginName");
return -1;
@ -1791,6 +1793,8 @@ class User extends CommonObject
$this->fk_warehouse = (int) $this->fk_warehouse;
// Check parameters
$badCharUnauthorizedIntoLoginName = getDolGlobalString('MAIN_LOGIN_BADCHARUNAUTHORIZED', ',@<>"\'');
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
@ -1800,7 +1804,7 @@ class User extends CommonObject
$langs->load("errors");
$this->error = $langs->trans("ErrorFieldRequired", 'Login');
return -1;
} elseif (preg_match('/[,@<>"\']/', $this->login)) {
} elseif (preg_match('/['.preg_quote($badCharUnauthorizedIntoLoginName, '/').']/', $this->login)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadCharIntoLoginName");
return -1;