From b90dcede9055dba770cbf66ce550a83d75062b85 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 3 Oct 2021 18:45:18 +0200 Subject: [PATCH] fix parsing with no street data and of custom fields --- api/src/Contacts/JsContact.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api/src/Contacts/JsContact.php b/api/src/Contacts/JsContact.php index f750835946..c456c27583 100644 --- a/api/src/Contacts/JsContact.php +++ b/api/src/Contacts/JsContact.php @@ -173,7 +173,7 @@ class JsContact break; case 'egroupware.org:customfields': - $contact += self::parseCustomfields($value); + $contact += self::parseCustomfields($value, $strict); break; case 'egroupware.org:assistant': @@ -433,8 +433,12 @@ class JsContact foreach($definitions as $name => $definition) { $data = $cfs[$name]; - if (isset($data[$name])) + if (isset($data)) { + if (is_scalar($data)) + { + $data = ['value' => $data]; + } if (!is_array($data) || !array_key_exists('value', $data)) { throw new \InvalidArgumentException("Invalid customfield object $name: ".json_encode($data, self::JSON_OPTIONS_ERROR)); @@ -614,7 +618,10 @@ class JsContact $prefix = $type === 'work' ? 'adr_one_' : 'adr_two_'; $contact = [$prefix.'street' => null, $prefix.'street2' => null]; - list($contact[$prefix.'street'], $contact[$prefix.'street2']) = self::parseStreetComponents($address['street'], $stict); + if (!empty($address['street'])) + { + list($contact[$prefix.'street'], $contact[$prefix.'street2']) = self::parseStreetComponents($address['street'], $stict); + } foreach(self::$jsAddress2attr+self::$jsAddress2workAttr as $js => $attr) { if (isset($address[$js]) && !is_string($address[$js]))