Fix defect found testing EMAIL content types.
This commit is contained in:
parent
2a48974f3a
commit
a0cd676521
@ -388,7 +388,7 @@ func newVC3_Email*(
|
||||
emailType = @[$etInternet],
|
||||
group = none[string]()): VC3_Email =
|
||||
|
||||
return VC3_Email(name: "EMAIL", emailType: emailType, group: group)
|
||||
return assignFields(VC3_Email(name: "EMAIL"), value, emailType, group)
|
||||
|
||||
func newVC3_Mailer*(
|
||||
value: string,
|
||||
@ -551,7 +551,7 @@ func newVC3_XType*(
|
||||
xParams: seq[VC3_XParam] = @[],
|
||||
group = none[string]()): VC3_XType =
|
||||
|
||||
if not name.startsWith("x-"):
|
||||
if not name.startsWith("X-"):
|
||||
raise newException(ValueError, "Extended types must begin with 'x-'.")
|
||||
|
||||
return assignFields(
|
||||
@ -1294,8 +1294,10 @@ proc serialize(r: VC3_Rev): string =
|
||||
result = r.nameWithGroup
|
||||
if r.valueType.isSome and r.valueType.get == "date-time":
|
||||
result &= ";VALUE=date-time:" & r.value.format(DATETIME_FMT)
|
||||
elif r.valueType.isSome and r.valueType.get == "date":
|
||||
result &= ";VALUE=date-time:" & r.value.format(DATETIME_FMT)
|
||||
else:
|
||||
result &= ";VALUE=date:" & r.value.format(DATE_FMT)
|
||||
result &= r.value.format(DATETIME_FMT)
|
||||
|
||||
proc serialize(u: VC3_UID | VC3_URL | VC3_VERSION | VC3_Class): string =
|
||||
result = u.nameWithGroup & ":" & u.value
|
||||
@ -1801,7 +1803,7 @@ proc parseContentLines(p: var VC3Parser): seq[VC3_Content] =
|
||||
isInline = params.existsWithValue("ENCODING", "B")))
|
||||
|
||||
else:
|
||||
if not name.startsWith("x-"):
|
||||
if not name.startsWith("X-"):
|
||||
p.error("unrecognized content type: '$1'" % [name])
|
||||
|
||||
result.add(newVC3_XType(
|
||||
|
26
tests/jdb.vcf
Executable file
26
tests/jdb.vcf
Executable file
@ -0,0 +1,26 @@
|
||||
BEGIN:VCARD
|
||||
PRODID:-//CyrusIMAP.org//Cyrus 3.7.0-alpha0-927-gf4c98c8499-fm-202208..//EN
|
||||
VERSION:3.0
|
||||
UID:cdaf67dc-b702-41ac-9c26-bb61df3032d2
|
||||
N:Bernard;Jonathan;;;
|
||||
FN:Jonathan Bernard
|
||||
ORG:;
|
||||
TITLE:
|
||||
NICKNAME:
|
||||
NOTE:
|
||||
REV:20220908T122102Z
|
||||
EMAIL;TYPE=home;TYPE=pref:jonathan@jdbernard.com
|
||||
EMAIL;TYPE=work:jdb@jdb-software.com
|
||||
email2.X-ABLabel:Obsolete
|
||||
email2.EMAIL:jonathan.bernard@sailpoint.com
|
||||
email3.X-ABLabel:Obsolete
|
||||
email3.EMAIL:jonathan.bernard@accenture.com
|
||||
email4.X-ABLabel:Obsolete
|
||||
email4.EMAIL:jbernard@fairwaytech.com
|
||||
email5.X-ABLabel:Obsolete
|
||||
email5.EMAIL:jobernar@linkedin.com
|
||||
EMAIL;TYPE=work:jbernard@vectra.ai
|
||||
TEL;TYPE=CELL:(512) 777-1602
|
||||
tel1.X-ABLabel:Mobile (alernate)
|
||||
tel1.TEL:(512) 784-2388
|
||||
END:VCARD
|
@ -53,3 +53,11 @@ suite "vcard/vcard3":
|
||||
vcards[0].fn.value == "Frank Dawson"
|
||||
vcards[0].email.len == 2
|
||||
(vcards[0].email --> find(it.emailType.contains("PREF"))).isSome
|
||||
|
||||
test "Jonathan Bernard VCard":
|
||||
#const jdbVcard = readFile("tests/jdb.vcf")
|
||||
let jdb = parseVCard3File("tests/jdb.vcf")[0]
|
||||
check:
|
||||
jdb.email.len == 7
|
||||
jdb.email[0].value == "jonathan@jdbernard.com"
|
||||
jdb.fn.value == "Jonathan Bernard"
|
||||
|
Loading…
x
Reference in New Issue
Block a user