Skip to content

UID wrong for V3 #27

@michaelof

Description

@michaelof

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
  • UID is added to vcard like $UID . "UID:" . $UID
  • ONLY happens for V3, V4 is fine.

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions