6.0.0-alpha14
7/3/25

[#7407] Photos: storing in LDAP and broken contact sync
Summary Photos: storing in LDAP and broken contact sync
Queue Turba
Queue Version 2.3
Type Bug
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester xk3 (at) mompl (dot) org
Created 09/29/2008 (6121 days ago)
Due
Updated 04/13/2010 (5560 days ago)
Assigned 10/24/2008 (6096 days ago)
Resolved 08/18/2009 (5798 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch Yes

History
04/13/2010 09:23:33 AM asd (at) asdf (dot) com Comment #15 Reply to this comment

[Show Quoted Text - 217 lines]
08/18/2009 05:07:29 PM Jan Schneider Comment #13
State ⇒ Resolved
Reply to this comment
Committed your changes, thanks!
08/18/2009 05:00:10 PM CVS Commit Comment #11 Reply to this comment
03/22/2009 02:47:02 PM xk3 (at) mompl (dot) org Comment #10 Reply to this comment
Finally, the problem 1) of comment #1 of this ticket is still not
solved. I still have to patch the function _emptyAttributeFilter.
I meant:  1) of the 1st comment of this ticket #7407
03/22/2009 02:44:23 PM xk3 (at) mompl (dot) org Comment #9 Reply to this comment
     * 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('/(\r\n|\r|\n)PHOTO;ENCODING=b[^:]*:(.+?)(\r\n|\r|\n)/',

       '\1PHOTO;ENCODING=BASE64:\1\2\1\1',

       $content, 1);



     $GLOBALS['backend']->logFile(

       SYNCML_LOGFILE_DATA,

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

     return array($content, $contentType);

}



Reasons:

a) Nokia expects "BASE64" as encoding string, not "b" (which is base64)

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

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


10/29/2008 12:47:47 AM Michael Rubinsky Comment #8 Reply to this comment
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.
That would be nice indeed, and would have to be added to
Horde_Form_Type_image. Please file a separate enhancement request for
that.
FYI - there is crop support in Ansel's photo editor, so you can look 
at the code there possibly for implementation, or maybe even somehow 
time the editing into Ansel itself.
10/29/2008 12:28:00 AM Jan Schneider Comment #7 Reply to this comment
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
This change is not necessary. The attribute is parsed fine with the 
extra blank line already.
4) In toHash and tovCard, the encoding of a photo is tested against
     and set to 'b'. Is that a valid encoding name at all? Changed
     it to 'base64' and it worked again. In turba/lib/Driver.php
It's actually the only valid value. BASE64 is not valid and breaking 
RFCs. We are reading it now anyway.
5) Finally, how am I supposed to delete a photo from a contact or save
Not at all, yet.
     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.
Right mouse click.
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.
That would be nice indeed, and would have to be added to 
Horde_Form_Type_image. Please file a separate enhancement request for 
that.
10/28/2008 11:36:04 PM CVS Commit Comment #6 Reply to this comment
10/28/2008 11:35:18 PM CVS Commit Comment #5 Reply to this comment
Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/turba/lib/Driver.php?r1=1.222&r2=1.223&ty=u
10/24/2008 10:09:59 AM Jan Schneider State ⇒ Assigned
 
10/24/2008 09:59:21 AM robb (at) wtg (dot) cw (dot) com Comment #4
New Attachment: data.txt Download
Reply to this comment
Please provide a real world example vCard. These patches break all
kind of stuff.
as attached




10/23/2008 10:24:50 PM Jan Schneider Comment #3
State ⇒ Feedback
Reply to this comment
Please provide a real world example vCard. These patches break all 
kind of stuff.
10/23/2008 04:53:24 PM Jan Schneider Summary ⇒ Photos: storing in LDAP and broken contact sync
 
10/07/2008 01:05:44 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Assigned
Patch ⇒ Yes
 
09/30/2008 01:23:39 PM robb (at) wtg (dot) cw (dot) com New Attachment: horde-photo.patch Download
 
09/30/2008 01:22:40 PM robb (at) wtg (dot) cw (dot) com Comment #2
New Attachment: turba-photo.patch Download
Reply to this comment
have test above changes, works for me



have created patches for convenience
09/29/2008 02:11:12 PM xk3 (at) mompl (dot) org Comment #1
Milestone ⇒
State ⇒ Unconfirmed
Patch ⇒ No
Queue ⇒ Turba
Summary ⇒ Photos: storing in LDAP and broken conatct sync
Type ⇒ Bug
Priority ⇒ 2. Medium
Reply to this comment
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 != '');

          } else {

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

              foreach ($var as $v) {

         ...



Storing in turba DB doesn'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('/[\r\n]+[ \t]/', '', $vCal);

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

+       $vCal = preg_replace('/\r\n\r\n/', "\r\n", $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 'photo':

              case 'logo':

                  $params = array('ENCODING' => 'base64');

                  if (isset($hash[$key . 'type'])) {

                      $params['TYPE'] = $hash[$key . 'type'];

                  }

                  $vcard->setAttribute(String::upper($key),

-                                    base64_encode($val),

+                                    base64_encode($val) . "\r\n",

                                       $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->hasValue($this->columns[$c - 1])) {

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

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

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

htmlspecialchars($value);

          if ($type == 'email') {



     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 'b'. Is that a valid encoding name at all? Changed

     it to 'base64' and it worked again. In turba/lib/Driver.php



              case 'photo':

              case 'logo':

-               $params = array('ENCODING' => 'b');

+               $params = array('ENCODING' => 'base64');





                  if (!isset($item['params']['ENCODING']) ||

-                   String::lower($item['params']['ENCODING']) != 'b') {

+                   String::lower($item['params']['ENCODING']) != 'base64') {

                      // 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.

Saved Queries