Fix vCard 3 PROFILE and AGENT handling

Parse PROFILE as the concrete VC3_Profile type instead of a bare
VC3_Property, and validate PROFILE parameters under the correct
content-type name.

Preserve AGENT values in newVC3_Agent so both parsed and constructed
AGENT properties serialize with their actual URI or inline content.

Expand regression coverage to verify PROFILE is exposed and serialized
as the standard property, parsed AGENT URI values round-trip correctly,
and constructed AGENT values retain their content.

AI-Assisted: yes
AI-Tool: OpenAI Codex / gpt-5.4 xhigh
This commit is contained in:
2026-03-28 13:33:01 -05:00
parent 8f2a05cde6
commit cfac536d60
2 changed files with 16 additions and 4 deletions

View File

@@ -520,7 +520,11 @@ func newVC3_Agent*(
isInline = true, isInline = true,
group = none[string]()): VC3_Agent = group = none[string]()): VC3_Agent =
return VC3_Agent(name: $pnAgent, isInline: isInline, group: group) return VC3_Agent(
name: $pnAgent,
value: value,
isInline: isInline,
group: group)
func newVC3_Org*( func newVC3_Org*(
value: seq[string], value: seq[string],
@@ -1067,8 +1071,8 @@ proc parseContentLines*(p: var VCardParser): seq[VC3_Property] =
if p.readValue.toUpper != "VCARD": if p.readValue.toUpper != "VCARD":
p.error("the value of the PROFILE content type must be \"$1\"" % p.error("the value of the PROFILE content type must be \"$1\"" %
["vcard"]) ["vcard"])
p.validateNoParameters(params, "NAME") p.validateNoParameters(params, "PROFILE")
result.add(VC3_Property(group: group, name: name)) result.add(newVC3_Profile(group))
of $pnSource: of $pnSource:
p.validateRequiredParameters(params, p.validateRequiredParameters(params,

View File

@@ -240,7 +240,9 @@ suite "vcard/vcard3":
"FN:John Smith", "FN:John Smith",
"N:Smith;John;;;")) "N:Smith;John;;;"))
check parsed.profile.isSome check:
parsed.profile.isSome
($parsed).contains("PROFILE:VCARD")
test "spec: AGENT uri values survive parse and serialize": test "spec: AGENT uri values survive parse and serialize":
let serialized = $parseSingleVCard3(vcard3Doc( let serialized = $parseSingleVCard3(vcard3Doc(
@@ -251,6 +253,12 @@ suite "vcard/vcard3":
check serialized.contains("AGENT;VALUE=uri:mailto:assistant@example.com") check serialized.contains("AGENT;VALUE=uri:mailto:assistant@example.com")
test "spec: constructed AGENT values serialize with their content":
let vc = newMinimalVCard3()
vc.add(newVC3_Agent("mailto:assistant@example.com", isInline = false))
check ($vc).contains("AGENT;VALUE=uri:mailto:assistant@example.com")
test "spec: folded lines may continue with horizontal tab": test "spec: folded lines may continue with horizontal tab":
let parsed = parseSingleVCard3( let parsed = parseSingleVCard3(
"BEGIN:VCARD\r\n" & "BEGIN:VCARD\r\n" &