fixed formatting of DN with escaped commas

This commit is contained in:
Roland Gruber 2019-11-09 14:32:35 +01:00
parent d991ec578c
commit b0d786c86e
2 changed files with 12 additions and 1 deletions

View File

@ -1053,6 +1053,7 @@ function getAbstractDN($dn) {
if ($dn == '') {
return '';
}
$dn = str_replace('\\,', '\\2C', $dn);
$parts = explode(',', $dn);
for ($i = 0; $i < sizeof($parts); $i++) {
$subparts = explode('=', $parts[$i]);
@ -1060,7 +1061,8 @@ function getAbstractDN($dn) {
$parts[$i] = $subparts[1];
}
}
return implode(' > ', $parts);
$abstractDn = implode(' > ', $parts);
return str_replace(array('\\2C', '\\,'), array(',', ','), $abstractDn);
}
/**

View File

@ -135,4 +135,13 @@ class AccountTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('cn=test\\2C user,ou=People,o=test,c=de', convertCommaEscaping('cn=test\\, user,ou=People,o=test,c=de'));
}
/**
* Tests getAbstractDN().
*/
function testGetAbstractDN() {
$this->assertEquals('test > test > de', getAbstractDN('cn=test,o=test,c=de'));
$this->assertEquals('test,user > test > de', getAbstractDN('cn=test\\,user,o=test,c=de'));
$this->assertEquals('test,user > test > de', getAbstractDN('cn=test\\2Cuser,o=test,c=de'));
}
}