Bläddra i källkod

Merge branch 'hotfix/184'

Close #184
Matthew Weier O'Phinney 12 år sedan
förälder
incheckning
583d90e216
1 ändrade filer med 15 tillägg och 2 borttagningar
  1. 15 2
      library/Zend/Ldap/Converter.php

+ 15 - 2
library/Zend/Ldap/Converter.php

@@ -69,11 +69,24 @@ class Zend_Ldap_Converter
      */
     public static function hex32ToAsc($string)
     {
-        $string = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $string);
+        // Using a callback, since PHP 5.5 has deprecated the /e modifier in preg_replace.
+        $string = preg_replace_callback("/\\\([0-9A-Fa-f]{2})/", array('Zend_Ldap_Converter', '_charHex32ToAsc'), $string);
         return $string;
     }
 
     /**
+     * Convert a single slash-prefixed character from Hex32 to ASCII.
+     * Used as a callback in @see hex32ToAsc()
+     * @param array $matches
+     *
+     * @return string
+     */
+    private static function _charHex32ToAsc(array $matches)
+    {
+        return chr(hexdec($matches[0]));
+    }
+
+    /**
      * Convert any value to an LDAP-compatible value.
      *
      * By setting the <var>$type</var>-parameter the conversion of a certain
@@ -394,4 +407,4 @@ class Zend_Ldap_Converter
         }
         return $v;
     }
-}
+}