Merge pull request #26865 from nextcloud/backport/26845/stable21
[stable21] fix creating vcards with multiple string values
This commit is contained in:
commit
1cdb80bb70
|
@ -150,13 +150,17 @@ class AddressBookImpl implements IAddressBook {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$vCard->remove($key);
|
$vCard->remove($key);
|
||||||
foreach ($value as $entry) {
|
foreach ($value as $entry) {
|
||||||
if (($key === "ADR" || $key === "PHOTO") && is_string($entry["value"])) {
|
if (is_string($entry)) {
|
||||||
$entry["value"] = stripslashes($entry["value"]);
|
$property = $vCard->createProperty($key, $entry);
|
||||||
$entry["value"] = explode(';', $entry["value"]);
|
} else {
|
||||||
}
|
if (($key === "ADR" || $key === "PHOTO") && is_string($entry["value"])) {
|
||||||
$property = $vCard->createProperty($key, $entry["value"]);
|
$entry["value"] = stripslashes($entry["value"]);
|
||||||
if (isset($entry["type"])) {
|
$entry["value"] = explode(';', $entry["value"]);
|
||||||
$property->add('TYPE', $entry["type"]);
|
}
|
||||||
|
$property = $vCard->createProperty($key, $entry["value"]);
|
||||||
|
if (isset($entry["type"])) {
|
||||||
|
$property->add('TYPE', $entry["type"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$vCard->add($property);
|
$vCard->add($property);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,11 +154,20 @@ class AddressBookImplTest extends TestCase {
|
||||||
->setMethods(['vCard2Array', 'createUid', 'createEmptyVCard'])
|
->setMethods(['vCard2Array', 'createUid', 'createEmptyVCard'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
$expectedProperties = 0;
|
||||||
|
foreach ($properties as $data) {
|
||||||
|
if (is_string($data)) {
|
||||||
|
$expectedProperties++;
|
||||||
|
} else {
|
||||||
|
$expectedProperties += count($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$addressBookImpl->expects($this->once())->method('createUid')
|
$addressBookImpl->expects($this->once())->method('createUid')
|
||||||
->willReturn($uid);
|
->willReturn($uid);
|
||||||
$addressBookImpl->expects($this->once())->method('createEmptyVCard')
|
$addressBookImpl->expects($this->once())->method('createEmptyVCard')
|
||||||
->with($uid)->willReturn($this->vCard);
|
->with($uid)->willReturn($this->vCard);
|
||||||
$this->vCard->expects($this->exactly(count($properties)))
|
$this->vCard->expects($this->exactly($expectedProperties))
|
||||||
->method('createProperty');
|
->method('createProperty');
|
||||||
$this->backend->expects($this->once())->method('createCard');
|
$this->backend->expects($this->once())->method('createCard');
|
||||||
$this->backend->expects($this->never())->method('updateCard');
|
$this->backend->expects($this->never())->method('updateCard');
|
||||||
|
@ -172,7 +181,8 @@ class AddressBookImplTest extends TestCase {
|
||||||
public function dataTestCreate() {
|
public function dataTestCreate() {
|
||||||
return [
|
return [
|
||||||
[[]],
|
[[]],
|
||||||
[['FN' => 'John Doe']]
|
[['FN' => 'John Doe']],
|
||||||
|
[['FN' => 'John Doe', 'EMAIL' => ['john@doe.cloud', 'john.doe@example.org']]],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue