From c77f9c75ec4f9e8d570887d45381a022413f8023 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 2 Aug 2013 21:01:14 +0000 Subject: [PATCH] PHP 5.5 fix --- lam/templates/3rdParty/pla/lib/ds_myldap.php | 20 +------------------- lam/templates/3rdParty/pla/lib/functions.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lam/templates/3rdParty/pla/lib/ds_myldap.php b/lam/templates/3rdParty/pla/lib/ds_myldap.php index 2dd4d1d5..cb07a837 100644 --- a/lam/templates/3rdParty/pla/lib/ds_myldap.php +++ b/lam/templates/3rdParty/pla/lib/ds_myldap.php @@ -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); diff --git a/lam/templates/3rdParty/pla/lib/functions.php b/lam/templates/3rdParty/pla/lib/functions.php index 85e004cc..3f46aedf 100644 --- a/lam/templates/3rdParty/pla/lib/functions.php +++ b/lam/templates/3rdParty/pla/lib/functions.php @@ -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)