<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Photos: storing in LDAP and broken contact sync</title> 
  <pubDate>Sat, 04 Apr 2026 10:12:43 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/7407</link> 
  <atom:link rel="self" type="application/rss+xml" title="Photos: storing in LDAP and broken contact sync" href="https://bugs.horde.org/ticket/7407/rss" /> 
  <description>Photos: storing in LDAP and broken contact sync</description> 
 
   
   
  <item> 
   <title>As follow up to closed #5971



Hi, just upgraded to current</title> 
   <description>As follow up to closed #5971



Hi, just upgraded to current turba 2.3

and run into some problems with PHOTO



1) storing contact without a photo in LDAP



The attribute array always contains an array for the photo item. If

there is no photo set, this array is empty, but is not catched by the

function _emptyAttributeFilter in turba/lib/Driver/ldap.php. This

results in an error in _add to LDAP. Stripping empty arrays too solves

at least this problem.



     function _emptyAttributeFilter($var)

     {

         if (!is_array($var)) {

             return ($var != &#039;&#039;);

         } else {

             if (count($var) == 0) { return false; }    &lt;&lt;===

             foreach ($var as $v) {

        ...



Storing in turba DB doesn&#039;t show this bug, but photos are stored as 0B

blobs instead of NULL blobs.







2) base64 is terminated by a blank line, so eliminate it before

    matching the following vCalender attributes. Otherwise the name of

    one following PHOTO will start with a \r\n, so it will be

    discarded afterward



    in /lib/Horde/iCalendar.php



         // Unfold any folded lines.

-       $vCal = preg_replace(&#039;/[\r\n]+[ \t]/&#039;, &#039;&#039;, $vCal);

+       $vCal = preg_replace(&#039;/[\r\n]+[ \t]+/&#039;, &#039;&#039;, $vCal);

+       $vCal = preg_replace(&#039;/\r\n\r\n/&#039;, &quot;\r\n&quot;, $vCal);



    (First line only beautifies the base64 code by stripping all

    whitespace. The second line does the necessary work by deleting all

    blank lines.)



    and add the blank line in /turba/lib/Driver.php again before

    sending to mobile:



             case &#039;photo&#039;:

             case &#039;logo&#039;:

                 $params = array(&#039;ENCODING&#039; =&gt; &#039;base64&#039;);

                 if (isset($hash[$key . &#039;type&#039;])) {

                     $params[&#039;TYPE&#039;] = $hash[$key . &#039;type&#039;];

                 }

                 $vcard-&gt;setAttribute(String::upper($key),

-                                    base64_encode($val),

+                                    base64_encode($val) . &quot;\r\n&quot;,

                                      $params);

                 break;







3) Browsing the address book with photo as a visible column results in a

    warning per entry containing a photo:



    Warning: htmlspecialchars() expects parameter 1 to be string, array

    given in 

/var/www/org.afaik.duff_ssl/mail-new/turba/templates/browse/row.inc

    on line 90



        if ($ob-&gt;hasValue($this-&gt;columns[$c - 1])) {

         $value = $ob-&gt;getValue($this-&gt;columns[$c - 1]);

-        $shown_columns[$c] = htmlspecialchars($value)

+        $shown_columns[$c] = is_array($value) ? $value : 

htmlspecialchars($value);

         if ($type == &#039;email&#039;) {



    No thinking on my side, just getting rid of this warning, so check

    again.







4) In toHash and tovCard, the encoding of a photo is tested against

    and set to &#039;b&#039;. Is that a valid encoding name at all? Changed

    it to &#039;base64&#039; and it worked again. In turba/lib/Driver.php



             case &#039;photo&#039;:

             case &#039;logo&#039;:

-               $params = array(&#039;ENCODING&#039; =&gt; &#039;b&#039;);

+               $params = array(&#039;ENCODING&#039; =&gt; &#039;base64&#039;);





                 if (!isset($item[&#039;params&#039;][&#039;ENCODING&#039;]) ||

-                   String::lower($item[&#039;params&#039;][&#039;ENCODING&#039;]) != &#039;b&#039;) {

+                   String::lower($item[&#039;params&#039;][&#039;ENCODING&#039;]) != &#039;base64&#039;) {

                     // Invalid property.

                     break;





5) Finally, how am I supposed to delete a photo from a contact or save

    it to a local file (e.g. for doing some cropping stuff in an external

    tool)? There are no delete and save buttons as for a common file.





Having this patched, I can add (ldap), change, view and sync photos



      Martin



PS: any thoughts on adding crop support? Photos taken by mobiles have 

a stupid format for contact photos. Otherwise, I could live with as 

save as local file button.</description> 
   <pubDate>Mon, 29 Sep 2008 14:11:12 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t49281</link> 
  </item> 
   
  <item> 
   <title>have test above changes, works for me



have created patche</title> 
   <description>have test above changes, works for me



have created patches for convenience</description> 
   <pubDate>Tue, 30 Sep 2008 13:22:40 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t49311</link> 
  </item> 
   
  <item> 
   <title>Please provide a real world example vCard. These patches bre</title> 
   <description>Please provide a real world example vCard. These patches break all kind of stuff.</description> 
   <pubDate>Thu, 23 Oct 2008 22:24:50 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t49926</link> 
  </item> 
   
  <item> 
   <title>&gt; Please provide a real world example vCard. These patches b</title> 
   <description>&gt; Please provide a real world example vCard. These patches break all 

&gt; kind of stuff.



as attached



</description> 
   <pubDate>Fri, 24 Oct 2008 09:59:21 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t49938</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/turba/lib/Driver.php?r1=1.222&amp;r2=1.223&amp;ty=u</description> 
   <pubDate>Tue, 28 Oct 2008 23:35:18 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t50133</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/turba/lib/tests/tohash.phpt?r1=1.14&amp;r2=1.15&amp;ty=u</description> 
   <pubDate>Tue, 28 Oct 2008 23:36:04 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t50134</link> 
  </item> 
   
  <item> 
   <title>&gt; 2) base64 is terminated by a blank line, so eliminate it b</title> 
   <description>&gt; 2) base64 is terminated by a blank line, so eliminate it before

&gt;     matching the following vCalender attributes. Otherwise the name of

&gt;     one following PHOTO will start with a \r\n, so it will be

&gt;     discarded afterward



This change is not necessary. The attribute is parsed fine with the extra blank line already.



&gt; 4) In toHash and tovCard, the encoding of a photo is tested against

&gt;     and set to &#039;b&#039;. Is that a valid encoding name at all? Changed

&gt;     it to &#039;base64&#039; and it worked again. In turba/lib/Driver.php



It&#039;s actually the only valid value. BASE64 is not valid and breaking RFCs. We are reading it now anyway.



&gt; 5) Finally, how am I supposed to delete a photo from a contact or save



Not at all, yet.



&gt;     it to a local file (e.g. for doing some cropping stuff in an external

&gt;     tool)? There are no delete and save buttons as for a common file.



Right mouse click.



&gt; PS: any thoughts on adding crop support? Photos taken by mobiles have

&gt; a stupid format for contact photos. Otherwise, I could live with as

&gt; save as local file button.



That would be nice indeed, and would have to be added to Horde_Form_Type_image. Please file a separate enhancement request for that.</description> 
   <pubDate>Wed, 29 Oct 2008 00:28:00 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t50141</link> 
  </item> 
   
  <item> 
   <title>&gt;&gt; PS: any thoughts on adding crop support? Photos taken by </title> 
   <description>&gt;&gt; PS: any thoughts on adding crop support? Photos taken by mobiles have

&gt;&gt; a stupid format for contact photos. Otherwise, I could live with as

&gt;&gt; save as local file button.

&gt;

&gt; That would be nice indeed, and would have to be added to 

&gt; Horde_Form_Type_image. Please file a separate enhancement request for 

&gt; that.



FYI - there is crop support in Ansel&#039;s photo editor, so you can look at the code there possibly for implementation, or maybe even somehow time the editing into Ansel itself.</description> 
   <pubDate>Wed, 29 Oct 2008 00:47:47 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t50142</link> 
  </item> 
   
  <item> 
   <title>    * Horde: 3.3.3

    * Turba: H3 (2.3.1)



I would like </title> 
   <description>    * Horde: 3.3.3

    * Turba: H3 (2.3.1)



I would like to add a comment on syncing photos with Nokia E51: data from the phone is parsed ok now, but syncing to the phone still needs some tweaking: I added the following function in ./lib/SyncML/Device/Nokia.php



function convertServer2Client($content, $contentType, $database)

{

  list($content, $contentType) =

    parent::convertServer2Client($content, $contentType);



    $content = preg_replace(&#039;/(\r\n|\r|\n)PHOTO;ENCODING=b[^:]*:(.+?)(\r\n|\r|\n)/&#039;,

      &#039;\1PHOTO;ENCODING=BASE64:\1\2\1\1&#039;,

      $content, 1);



    $GLOBALS[&#039;backend&#039;]-&gt;logFile(

      SYNCML_LOGFILE_DATA,

      &quot;\noutput converted for client ($contentType):\n$content\n&quot;);

    return array($content, $contentType);

}



Reasons:

a) Nokia expects &quot;BASE64&quot; as encoding string, not &quot;b&quot; (which is base64)

b) Extra file type info confuses the phone, so strip everything else before &quot;:&quot; 

c) base64 has to end with an extra blank line (the double \1\1)





Finally, the problem 1) of comment #1 of this ticket is still not solved. I still have to patch the function _emptyAttributeFilter.



cheers,

   Martin

</description> 
   <pubDate>Sun, 22 Mar 2009 14:44:23 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t53210</link> 
  </item> 
   
  <item> 
   <title>

&gt; Finally, the problem 1) of comment #1 of this ticket is </title> 
   <description>

&gt; Finally, the problem 1) of comment #1 of this ticket is still not 

&gt; solved. I still have to patch the function _emptyAttributeFilter.



I meant:  1) of the 1st comment of this ticket #7407</description> 
   <pubDate>Sun, 22 Mar 2009 14:47:02 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t53211</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/turba/lib/Driver/ldap.php?rt=horde&amp;r1=1.54.4.21&amp;r2=1.54.4.22&amp;ty=u</description> 
   <pubDate>Tue, 18 Aug 2009 17:00:10 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t55388</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/framework/SyncML/SyncML/Device/Nokia.php?rt=horde&amp;r1=1.17&amp;r2=1.18&amp;ty=u</description> 
   <pubDate>Tue, 18 Aug 2009 17:05:54 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t55389</link> 
  </item> 
   
  <item> 
   <title>Committed your changes, thanks!</title> 
   <description>Committed your changes, thanks!</description> 
   <pubDate>Tue, 18 Aug 2009 17:07:29 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t55390</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in Git for this ticket:

Filter out e</title> 
   <description>Changes have been made in Git for this ticket:

Filter out empty arrays (Bug #7407).

http://git.horde.org/diff.php/turba/lib/Driver/Ldap.php?rt=horde-git&amp;r1=ddd78a35dc892e2dbdcbab6f077366ed8972fc65&amp;r2=05a4fcce01e105c552dae2f1e2fdd363eaa2464b</description> 
   <pubDate>Wed, 13 Jan 2010 00:10:38 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t57602</link> 
  </item> 
   
  <item> 
   <title>&gt; As follow up to closed #5971
&gt;
&gt;
&gt;
&gt; Hi, just upgraded</title> 
   <description>&gt; As follow up to closed #5971
&gt;
&gt;
&gt;
&gt; Hi, just upgraded to current turba 2.3
&gt;
&gt; and run into some problems with PHOTO
&gt;
&gt;
&gt;
&gt; 1) storing contact without a photo in LDAP
&gt;
&gt;
&gt;
&gt; The attribute array always contains an array for the photo item. If
&gt;
&gt; there is no photo set, this array is empty, but is not catched by the
&gt;
&gt; function _emptyAttributeFilter in turba/lib/Driver/ldap.php. This
&gt;
&gt; results in an error in _add to LDAP. Stripping empty arrays too solves
&gt;
&gt; at least this problem.
&gt;
&gt;
&gt;
&gt;      function _emptyAttributeFilter($var)
&gt;
&gt;      {
&gt;
&gt;          if (!is_array($var)) {
&gt;
&gt;              return ($var != &#039;&#039;);
&gt;
&gt;          } else {
&gt;
&gt;              if (count($var) == 0) { return false; }    &lt;&lt;===
&gt;
&gt;              foreach ($var as $v) {
&gt;
&gt;         ...
&gt;
&gt;
&gt;
&gt; Storing in turba DB doesn&#039;t show this bug, but photos are stored as 0B
&gt;
&gt; blobs instead of NULL blobs.
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; 2) base64 is terminated by a blank line, so eliminate it before
&gt;
&gt;     matching the following vCalender attributes. Otherwise the name of
&gt;
&gt;     one following PHOTO will start with a \r\n, so it will be
&gt;
&gt;     discarded afterward
&gt;
&gt;
&gt;
&gt;     in /lib/Horde/iCalendar.php
&gt;
&gt;
&gt;
&gt;          // Unfold any folded lines.
&gt;
&gt; -       $vCal = preg_replace(&#039;/[\r\n]+[ \t]/&#039;, &#039;&#039;, $vCal);
&gt;
&gt; +       $vCal = preg_replace(&#039;/[\r\n]+[ \t]+/&#039;, &#039;&#039;, $vCal);
&gt;
&gt; +       $vCal = preg_replace(&#039;/\r\n\r\n/&#039;, &quot;\r\n&quot;, $vCal);
&gt;
&gt;
&gt;
&gt;     (First line only beautifies the base64 code by stripping all
&gt;
&gt;     whitespace. The second line does the necessary work by deleting all
&gt;
&gt;     blank lines.)
&gt;
&gt;
&gt;
&gt;     and add the blank line in /turba/lib/Driver.php again before
&gt;
&gt;     sending to mobile:
&gt;
&gt;
&gt;
&gt;              case &#039;photo&#039;:
&gt;
&gt;              case &#039;logo&#039;:
&gt;
&gt;                  $params = array(&#039;ENCODING&#039; =&gt; &#039;base64&#039;);
&gt;
&gt;                  if (isset($hash[$key . &#039;type&#039;])) {
&gt;
&gt;                      $params[&#039;TYPE&#039;] = $hash[$key . &#039;type&#039;];
&gt;
&gt;                  }
&gt;
&gt;                  $vcard-&gt;setAttribute(String::upper($key),
&gt;
&gt; -                                    base64_encode($val),
&gt;
&gt; +                                    base64_encode($val) . &quot;\r\n&quot;,
&gt;
&gt;                                       $params);
&gt;
&gt;                  break;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; 3) Browsing the address book with photo as a visible column results in a
&gt;
&gt;     warning per entry containing a photo:
&gt;
&gt;
&gt;
&gt;     Warning: htmlspecialchars() expects parameter 1 to be string, array
&gt;
&gt;     given in
&gt;
&gt; /var/www/org.afaik.duff_ssl/mail-new/turba/templates/browse/row.inc
&gt;
&gt;     on line 90
&gt;
&gt;
&gt;
&gt;         if ($ob-&gt;hasValue($this-&gt;columns[$c - 1])) {
&gt;
&gt;          $value = $ob-&gt;getValue($this-&gt;columns[$c - 1]);
&gt;
&gt; -        $shown_columns[$c] = htmlspecialchars($value)
&gt;
&gt; +        $shown_columns[$c] = is_array($value) ? $value :
&gt;
&gt; htmlspecialchars($value);
&gt;
&gt;          if ($type == &#039;email&#039;) {
&gt;
&gt;
&gt;
&gt;     No thinking on my side, just getting rid of this warning, so check
&gt;
&gt;     again.
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; 4) In toHash and tovCard, the encoding of a photo is tested against
&gt;
&gt;     and set to &#039;b&#039;. Is that a valid encoding name at all? Changed
&gt;
&gt;     it to &#039;base64&#039; and it worked again. In turba/lib/Driver.php
&gt;
&gt;
&gt;
&gt;              case &#039;photo&#039;:
&gt;
&gt;              case &#039;logo&#039;:
&gt;
&gt; -               $params = array(&#039;ENCODING&#039; =&gt; &#039;b&#039;);
&gt;
&gt; +               $params = array(&#039;ENCODING&#039; =&gt; &#039;base64&#039;);
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;                  if (!isset($item[&#039;params&#039;][&#039;ENCODING&#039;]) ||
&gt;
&gt; -                   String::lower($item[&#039;params&#039;][&#039;ENCODING&#039;]) != &#039;b&#039;) {
&gt;
&gt; +                   String::lower($item[&#039;params&#039;][&#039;ENCODING&#039;]) != &#039;base64&#039;) {
&gt;
&gt;                      // Invalid property.
&gt;
&gt;                      break;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; 5) Finally, how am I supposed to delete a photo from a contact or save
&gt;
&gt;     it to a local file (e.g. for doing some cropping stuff in an external
&gt;
&gt;     tool)? There are no delete and save buttons as for a common file.
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; Having this patched, I can add (ldap), change, view and sync photos
&gt;
&gt;
&gt;
&gt;       Martin
&gt;
&gt;
&gt;
&gt; PS: any thoughts on adding crop support? Photos taken by mobiles have
&gt;
&gt; a stupid format for contact photos. Otherwise, I could live with as
&gt;
&gt; save as local file button.
</description> 
   <pubDate>Tue, 13 Apr 2010 09:23:33 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7407#t58459</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
