input_check() now removes non-ASCII characters when found
This commit is contained in:
parent
579d94d031
commit
98cc8373e7
|
@ -521,12 +521,15 @@ class baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function input_check() {
|
/**
|
||||||
/* We have to some string checks now. Not every ldap attributes allow utf8
|
* Checks if the attribute values follow the LDAP syntax.
|
||||||
* strings. Therefore we do a syntax check here and change utf8 strings to ascci
|
* Not every LDAP attribute allows UTF-8 strings. Therefore we do a syntax check here
|
||||||
* strings. Only "7bit" ascci is allowed
|
* and change UTF-8 strings to ASCII strings if needed.
|
||||||
* We check als the max length as defined in ldap.
|
* The maximum length of the attributes is checked, too.
|
||||||
|
*
|
||||||
|
* @return mixed 0 if no errors/warnings occured, otherwise an array of status messages.
|
||||||
*/
|
*/
|
||||||
|
function input_check() {
|
||||||
// Do a check for every ldap attribute
|
// Do a check for every ldap attribute
|
||||||
$attributes = array_keys($this->attributes);
|
$attributes = array_keys($this->attributes);
|
||||||
for ($i=0; $i<count($attributes); $i++) {
|
for ($i=0; $i<count($attributes); $i++) {
|
||||||
|
@ -543,15 +546,29 @@ class baseModule {
|
||||||
$_SESSION['ldap']->attributes[$attributes[$i]]['SYNTAX']=='1.3.6.1.4.1.1466.115.121.1.11') {
|
$_SESSION['ldap']->attributes[$attributes[$i]]['SYNTAX']=='1.3.6.1.4.1.1466.115.121.1.11') {
|
||||||
// found "7bit" ascii attribute
|
// found "7bit" ascii attribute
|
||||||
// convert utf8 in us-ascii
|
// convert utf8 in us-ascii
|
||||||
$convert = array ( 'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'ue',
|
$convert = array ( 'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'Ue',
|
||||||
'ß' => 'ss', 'é' => 'e', 'è' => 'e', 'ô' => 'o'
|
'ß' => 'ss', 'é' => 'e', 'è' => 'e', 'ô' => 'o', 'ç' => 'c'
|
||||||
);
|
);
|
||||||
$index = array_keys($convert);
|
$index = array_keys($convert);
|
||||||
for ($j=0; $j<count($this->attributes[$attributes[$i]]); $j++)
|
for ($j=0; $j<count($this->attributes[$attributes[$i]]); $j++) {
|
||||||
|
$replaced = false;
|
||||||
|
// replace special characters
|
||||||
for ($k=0; $k<count($index); $k++) {
|
for ($k=0; $k<count($index); $k++) {
|
||||||
$temp = str_replace($index[$k], $convert[$index[$k]], $this->attributes[$attributes[$i]][$j]);
|
$temp = str_replace($index[$k], $convert[$index[$k]], $this->attributes[$attributes[$i]][$j]);
|
||||||
if ($temp!=$this->attributes[$attributes[$i]][$j]) {
|
if ($temp!=$this->attributes[$attributes[$i]][$j]) {
|
||||||
$this->attributes[$attributes[$i]][$j] = $temp;
|
$this->attributes[$attributes[$i]][$j] = $temp;
|
||||||
|
$replaced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove remaining UTF-8 characters
|
||||||
|
for ($c = 0; $c < strlen($this->attributes[$attributes[$i]][$j]); $c++) {
|
||||||
|
if (ord($this->attributes[$attributes[$i]][$j][$c]) > 127) {
|
||||||
|
$this->attributes[$attributes[$i]][$j] = substr($this->attributes[$attributes[$i]][$j], 0, $c) .
|
||||||
|
substr($this->attributes[$attributes[$i]][$j], $c + 2);
|
||||||
|
$replaced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($replaced) {
|
||||||
$messages[$attributes[$i]][] = array('WARN', _($attributes[$i]), _('Changed value because only ASCII characters are allowed.'));
|
$messages[$attributes[$i]][] = array('WARN', _($attributes[$i]), _('Changed value because only ASCII characters are allowed.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue