worthmine / Text-vCard-Precisely

Read, Write or Edit vCard 3.0 or 4.0 with perl
https://metacpan.org/pod/Text::vCard::Precisely
Other
3 stars 3 forks source link

UID wrong for V3 #27

Open michaelof opened 4 years ago

michaelof commented 4 years ago

Daily report :)

The following small script

#!/usr/bin/perl
use strict;
use warnings;
use utf8;

use Text::vCard::Precisely;
use UUID::Generator::PurePerl;

my $vc = Text::vCard::Precisely->new( version => '3.0' );
$vc->fn( "Forrest Gump" );

$vc->uid( build_uid() );
print $vc->as_string();
$vc->as_file("uid.vcf");

sub build_uid {
   my $ug = UUID::Generator::PurePerl->new();
   my $uuid1 = $ug->generate_v1();
   return "urn:uuid:" . $uuid1->as_string();
};

produces the following vcard:

BEGIN:VCARD
VERSION:3.0
FN:Forrest Gump
urn:uuid:25fbdd3c-1b08-11eb-8081-df39046b72faUID:urn:uuid:25fbdd3c-1b08-
  11eb-8081-df39046b72fa
END:VCARD

Remark: You're enforcing UIDs as

subtype 'UID' => as 'Str' =>
    where {m/^urn:uuid:[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/is}
=> message {"The UID you provided, $_, was not correct"};
has uid => ( is => 'rw', isa => 'UID' );

for both V3 and V4. This is very strict, but fine. Follows RFC 6350 https://tools.ietf.org/html/rfc6350#section-6.7.6 recommendation

The "uuid" URN namespace defined in
      [RFC4122] is particularly well suited to this task, but other URI
      schemes MAY be used.  Free-form text MAY also be used.

But RFC 6350 allows free-form text also, RFC 2426 https://tools.ietf.org/html/rfc2426#section-3.6.7 allows "non-standard format"

worthmine commented 4 years ago

thank you for daily reporting 💯

I'll well read those later.

michaelof commented 3 years ago

Yuki,

@simcop2387 found out in IRC channel #perl where uid content string is currently duplicated, it's in https://github.com/worthmine/Text-vCard-Precisely/blob/master/lib/Text/vCard/Precisely/V3.pm#L278

Have to exclude uid

    NOTE SOUND UID URL KEY

to

    NOTE SOUND URL KEY

As far as I understood (at least) as long as you have the concatenations of uid in sub as_string.