From e3d6e09922aa90a36b0592505a2a4a529c447af6 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 23 Sep 2015 17:39:55 +0000 Subject: [PATCH] Fix import of vCard photos with ENCODING=BASE64 --- addressbook/inc/class.addressbook_egw_record.inc.php | 3 +-- addressbook/inc/class.addressbook_import_vcard.inc.php | 8 ++++---- addressbook/inc/class.addressbook_vcal.inc.php | 7 +++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addressbook/inc/class.addressbook_egw_record.inc.php b/addressbook/inc/class.addressbook_egw_record.inc.php index a37c48b987..66d48e6b89 100644 --- a/addressbook/inc/class.addressbook_egw_record.inc.php +++ b/addressbook/inc/class.addressbook_egw_record.inc.php @@ -78,8 +78,7 @@ class addressbook_egw_record implements importexport_iface_egw_record * @return array complete record as associative array */ public function get_record_array() { - // do not return binary jpeg, it messes up json data - return array_diff_key($this->contact, array('jpegphoto' => true)); + return $this->contact; } /** diff --git a/addressbook/inc/class.addressbook_import_vcard.inc.php b/addressbook/inc/class.addressbook_import_vcard.inc.php index e32bd09655..0252778401 100644 --- a/addressbook/inc/class.addressbook_import_vcard.inc.php +++ b/addressbook/inc/class.addressbook_import_vcard.inc.php @@ -121,8 +121,8 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { // Failures $this->errors = array(); - // Fix for Apple Addressbook - $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream)); + // Fix for Apple Addressbook + $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream)); $contacts = new egw_ical_iterator($vCard, '', $charset, array($this, '_vcard'),array( // Owner (addressbook) @@ -272,7 +272,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { foreach($this->preview_records as $i => $record) { // Convert to human-friendly - importexport_export_csv::convert($record,$record_class::$types,$_definition->application); + importexport_export_csv::convert($record,$record_class::$types,$_definition->application); $record = $record->get_record_array(); $row = array(); foreach($labels as $field => $label) @@ -282,7 +282,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { // Don't scare users, do something with jpeg if($field == 'jpegphoto' && $row[$field]) { - $row[$field] = '-ENCODED IMAGE-'; + $row[$field] = ''; } unset($record[$field]); } diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index 05140a3f01..4e31a44268 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -953,8 +953,11 @@ class addressbook_vcal extends addressbook_bo break; case 'jpegphoto': - $contact[$fieldName] = $vcardValues[$vcardKey]['params']['ENCODING'] == 'b' ? - base64_decode($vcardValues[$vcardKey]['value']): $vcardValues[$vcardKey]['value']; + $contact[$fieldName] = $vcardValues[$vcardKey]['value']; + if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64'))) + { + $contact[$fieldName] = base64_decode($contact[$fieldName]); + } break; case 'note':