ZF-10193: Zend_Ldap_Ldif_Encoder encode incorrectly boolean value
Description
Here is a patch to fix this issue:
--- a/usr/share/php/zf/Zend/Ldap/Ldif/Encoder.php
+++ b/usr/share/php/zf/Zend/Ldap/Ldif/Encoder.php
@@ -180,6 +180,10 @@ class Zend_Ldap_Ldif_Encoder
*/
protected function _encodeString($string, &$base64 = null)
{
+ if (is_bool($string)) {
+ $string = $string ? 'TRUE' : 'FALSE';
+ }
+
$string = (string)$string;
if (!is_numeric($string) && empty($string)) {
return '';
Comments
Posted by Stefan Gehrig (sgehrig) on 2010-07-25T10:50:48.000+0000
The Zend_Ldap_Ldif_Encoder originally was not designed to handle PHP datatypes and convert them into a LDIF representation. It was designed to convert LDAP data (retrieved from the LDAP e.g.) into LDIF data. A change in this behavior would be a bc-breaking change.
Furthermore it would duplicate conversion code from Zend_Ldap_Attribute into Zend_Ldap_Ldif_Encoder which is undesirable. Zend_Ldap_Attribute currently is the only component for converting PHP datatypes from and to LDAP data representation.
The current planing is to refactor Zend_Ldap_Attribute and put all the conversion code into Zend_Ldap_Converter (which currently is just a container for some low-level conversion methods). Zend_Ldap_Ldif_Encoder could then optionally use Zend_Ldap_Converter to allow for PHP datatypes to be directly converted into LDIF data.
Currently the workaround is to use Zend_Ldap_Attribute:
Posted by Stefan Gehrig (sgehrig) on 2010-09-22T10:06:49.000+0000
Should be solved with the new Zend_Ldap_Converter