From 59fe34752c3444aec70b01bb6f5f2c4f6f03bb01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Sep 2019 15:50:48 +0200 Subject: [PATCH 1/3] Fix error reporting of LDAP errors --- ...interface_50_modLdap_Ldapsynchro.class.php | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index b0fc6634a98..daa5ae9a525 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -621,7 +621,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[]="ErrorLDAP ".$ldap->error; + } } } elseif ($action == 'MEMBER_NEW_PASSWORD') @@ -644,7 +647,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result=$ldap->update($dn, $info, $user, $olddn); } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } } @@ -668,7 +674,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result=$ldap->update($dn, $info, $user, $olddn); } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } } @@ -721,7 +730,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } @@ -747,7 +759,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result=$ldap->add($dn, $info, $user); } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } elseif ($action == 'MEMBER_TYPE_MODIFY') @@ -788,7 +803,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result=$ldap->update($dn, $info, $user, $olddn); } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } elseif ($action == 'MEMBER_TYPE_DELETE') @@ -807,7 +824,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result=$ldap->delete($dn); } - if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; + if ($result <= 0) + { + $this->errors[] = "ErrorLDAP ".$ldap->error; + } } } From 8cff008156135771cd02eccfdbd0662ba2af3244 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Sep 2019 16:03:20 +0200 Subject: [PATCH 2/3] Fix error reporting --- htdocs/societe/class/societe.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2086c248bb1..1ef4de8ae64 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1159,6 +1159,7 @@ class Societe extends CommonObject if ($result < 0) { $this->error=$lmember->error; + $this->errors = array_merge($this->errors, $lmember->errors); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } From a126b1e538860368e98d53e867483744009ba42f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Sep 2019 22:25:44 +0200 Subject: [PATCH 3/3] FIX Add char $ and ; in sanitizing of filenames. --- htdocs/core/lib/functions.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5540feadd14..3d7c9ad0ae2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -796,8 +796,10 @@ function dol_size($size, $type = '') */ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) { - // List of special chars for filenames are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file - $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°'); + // List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file + // Char '>' '<' '|' '$' and ';' are special chars for shells. + // Char '/' and '\' are file delimiters. + $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';'); return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); }