Jonathan Bernard 201556ecbe Fix vCard 3 text escaping and decoding
Implement RFC 2426 text escaping consistently across vCard 3
serialization and parsing.

On serialization, escape backslashes, newlines, semicolons, and commas
for simple text properties, structured text components, and list-valued
text properties so generated FN, N, ADR, ORG, CATEGORIES, and related
properties are spec-compliant on the wire.

On parsing, decode escaped text for the properties that were previously
read as raw values: FN, NICKNAME, LABEL, MAILER, TITLE, ROLE, PRODID,
and SORT-STRING. This preserves existing structured-text parsing for N,
ADR, NOTE, ORG, and CATEGORIES while fixing the direct raw-value
mismatch identified in the review.

Add regression coverage for both directions: parsing escaped text values
and serializing escaped simple, structured, and list text values.

AI-Assisted: yes
AI-Tool: OpenAI Codex / gpt-5.4 xhigh
2026-03-28 10:27:37 -05:00
2023-05-03 02:16:18 -05:00
2023-05-03 07:11:32 -05:00

VCard

nim-vcard is a pure nim implementation of the VCard format defined in RFCs 2425, 2426, and 6350. It allows you to parse and serialize VCards, as well as create VCards programmatically. It aims to be a complete implememtation, supporting all of the features of the VCard3 standard. Because the standard provides many features that may be rarely used, this library also provides a simplified API for more typical use-cases.

Example Usage

BEGIN:VCARD
VERSION:3.0
UID: 5db6f100-e2d6-4e8d-951f-d920586bc069
N:Foster;Jack;Allen;;
FN:Allen Foster
REV:20230408T122102Z
EMAIL;TYPE=home;TYPE=pref:allen@fosters.test
EMAIL;TYPE=work:jack.foster@company.test
TEL;TYPE=CELL:+1 (555) 123-4567
END:VCARD

4839ff64a8/examples/simple.nim (L1-L22)

Future Goals

  • VCard 4.0 support

Debugging

Need to clean up and organize

Run tvcard3 tests in gdb:

$ cd tests
$ nim --debuginfo --linedir:on c tvcard3
$ gdb --tui tvcard3
Description
No description provided
Readme 430 KiB
Languages
Nim 99.6%
Makefile 0.4%