PHP 5.5 fix

This commit is contained in:
Roland Gruber 2013-08-02 21:01:14 +00:00
parent 80f74acbd0
commit c77f9c75ec
2 changed files with 13 additions and 21 deletions

View File

@ -1065,7 +1065,7 @@ class myldap extends DS {
# Record the forward and reverse entries in the cache.
foreach ($result as $key => $value) {
# translate hex code into ascii for display
$result[$key] = $this->unescapeDN($value);
$result[$key] = dn_unescape($value);
$CACHE['explode'][implode(',',$result[0])][$key] = $result[$key];
$CACHE['explode'][implode(',',array_reverse($result[0]))][$key] = array_reverse($result[$key]);
@ -1099,24 +1099,6 @@ class myldap extends DS {
return $dn;
}
/**
* Parse a DN and unescape any special characters
*/
private function unescapeDN($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
if (is_array($dn)) {
$a = array();
foreach ($dn as $key => $rdn)
$a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);
return $a;
} else
return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);
}
public function getRootDSE($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);

View File

@ -2393,15 +2393,25 @@ function dn_unescape($dn) {
$a = array();
foreach ($dn as $key => $rdn)
$a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);
$a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', 'convertHexStringToCharCallback', $rdn);
return $a;
} else {
return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);
return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', 'convertHexStringToCharCallback', $dn);
}
}
/**
* Converts a hex encoded string like \12 to the corresponding character.
*
* @param array $hex preg_replace_callback: matching hex string array
* @return String character
*/
function convertHexStringToCharCallback($hex) {
return chr(hexdec($hex[1]));
}
/**
* Fetches the URL for the specified item. This is a convenience function for
* fetching project HREFs (like bugs)