vobject icon indicating copy to clipboard operation
vobject copied to clipboard

Trailing semicolons ;;; in Name/N are reported as invalid

Open Maxim-Mazurok opened this issue 5 years ago • 2 comments

I have this vCard, generated by ez-vcard and it has no trailing semicolons for the N field:

BEGIN:VCARD
VERSION:2.1
N:Mazurok;Maxim
END:VCARD

But when I try to validate it like so:

$vcard = VObject\Reader::read(
    fopen(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "vcard.vcf", "r")
  );
$result = $vcard->validate(Sabre\VObject\Node::REPAIR);

it gives me a validation error and when I call $vcard->serialize(), it suggests to use this instead (with trailing semicolons):

BEGIN:VCARD
VERSION:2.1
N:Mazurok;Maxim;;;
END:VCARD

As mentioned in https://github.com/mangstadt/ez-vcard/issues/57#issuecomment-226665013, it's ok to trim trailing semicolons in the N field:

vCard 2.1 spec gives an example without the trailing semi-colons:

N:Veni, Vidi, Vici;The Restaurant.

So, should we fix this, or I'm just not using some optional arguments for validation?... I don't want validation to be forgiving, though. I want my vCard to be as close to spec, as possible.

Cheers!

Maxim-Mazurok avatar Oct 09 '20 08:10 Maxim-Mazurok

Looks like this is specifically by design: https://github.com/sabre-io/vobject/blob/0fec2b0c475f9318353b4a9c50441470397f6da4/lib/Property/Text.php#L50-L51

Maxim-Mazurok avatar Oct 09 '20 12:10 Maxim-Mazurok

Looks like it was added by @evert in https://github.com/sabre-io/vobject/commit/0806a4694296bd518b64463e611009d8641dc94d

Maxim-Mazurok avatar Oct 09 '20 12:10 Maxim-Mazurok