Merge pull request #66 from MichaelIT/master

Incompatable with openLDAP >=2.1.2
This commit is contained in:
Deon George 2019-04-18 11:58:12 +10:00 committed by GitHub
commit f3aad72b57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2487,6 +2487,30 @@ function draw_chooser_link($form,$element,$include_choose_text=true,$rdn='none')
printf('<span class="x-small"><a href="%s" title="%s">%s</a></span>',$href,$title,_('browse'));
}
/**
* http://php.net/manual/en/function.ldap-explode-dn.php#34724
* fixed for:
* Keep attention on UTF8 encoded DNs. Since openLDAP >=2.1.2
* ldap_explode_dn turns unprintable chars (in the ASCII sense, UTF8
* encoded) into \<hexcode>.
*/
function ldap_explode_dn_patch( $dn, $with_attrib ) {
$result = ldap_explode_dn( $dn, $with_attrib );
if (! $result ) return null;
# translate hex code into ascii again
foreach ( $result as $key => $value ) {
$result[ $key ] = preg_replace_callback(
"/\\\([0-9A-Fa-f]{2})/",
function ( $matches) {
return chr( hexdec( $matches[1] ) );
},
$value
);
}
return ( $result );
}
/**
* Explode a DN into an array of its RDN parts.
*
@ -2522,8 +2546,8 @@ function pla_explode_dn($dn,$with_attributes=0) {
$dn = addcslashes($dn,'<>+";');
# split the dn
$result[0] = ldap_explode_dn(dn_escape($dn),0);
$result[1] = ldap_explode_dn(dn_escape($dn),1);
$result[0] = ldap_explode_dn_patch(dn_escape($dn),0);
$result[1] = ldap_explode_dn_patch(dn_escape($dn),1);
if (! $result[$with_attributes]) {
if (DEBUG_ENABLED)
debug_log('Returning NULL - NO result.',1,0,__FILE__,__LINE__,__METHOD__);