mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-02-07 01:54:16 +01:00
Fix empty FN. Related: #353
This commit is contained in:
parent
0a59d6c164
commit
b0474d7da4
@ -12,6 +12,7 @@ namespace OCA\Contacts\Controller;
|
|||||||
use OCA\Contacts\App,
|
use OCA\Contacts\App,
|
||||||
OCA\Contacts\JSONResponse,
|
OCA\Contacts\JSONResponse,
|
||||||
OCA\Contacts\Controller,
|
OCA\Contacts\Controller,
|
||||||
|
OCA\Contacts\VObject\VCard as MyVCard,
|
||||||
Sabre\VObject;
|
Sabre\VObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,6 +239,13 @@ class ImportController extends Controller {
|
|||||||
continue; // Ditch cards that can't be parsed by Sabre.
|
continue; // Ditch cards that can't be parsed by Sabre.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
$vcard->validate(MyVCard::REPAIR|MyVCard::UPGRADE);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\OCP\Util::writeLog('contacts', __METHOD__ . ' ' .
|
||||||
|
'Error validating vcard: ' . $e->getMessage(), \OCP\Util::ERROR);
|
||||||
|
$failed += 1;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
* - Check if a contact with identical UID exists.
|
* - Check if a contact with identical UID exists.
|
||||||
|
@ -221,17 +221,21 @@ class VCard extends VObject\Component\VCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fn = $this->select('FN');
|
$fn = $this->select('FN');
|
||||||
if (count($fn) !== 1) {
|
if (count($fn) !== 1 || trim((string)$this->FN) === '') {
|
||||||
$warnings[] = array(
|
$warnings[] = array(
|
||||||
'level' => 1,
|
'level' => 1,
|
||||||
'message' => 'The FN property must appear in the VCARD component exactly 1 time',
|
'message' => 'The FN property must appear in the VCARD component exactly 1 time',
|
||||||
'node' => $this,
|
'node' => $this,
|
||||||
);
|
);
|
||||||
if (($options & self::REPAIR) && count($fn) === 0) {
|
if ($options & self::REPAIR) {
|
||||||
// We're going to try to see if we can use the contents of the
|
// We're going to try to see if we can use the contents of the
|
||||||
// N property.
|
// N property.
|
||||||
if (isset($this->N)) {
|
if (isset($this->N)
|
||||||
|
&& substr((string)$this->N, 2) !== ';;'
|
||||||
|
&& (string)$this->N !== ''
|
||||||
|
) {
|
||||||
$value = explode(';', (string)$this->N);
|
$value = explode(';', (string)$this->N);
|
||||||
if (isset($value[1]) && $value[1]) {
|
if (isset($value[1]) && $value[1]) {
|
||||||
$this->FN = $value[1] . ' ' . $value[0];
|
$this->FN = $value[1] . ' ' . $value[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user