Skip to content

[WIP] Adds support for vCard 2.1#389

Closed
caugner wants to merge 4 commits intokewisch:masterfrom
caugner:187-support-vcard-2.1
Closed

[WIP] Adds support for vCard 2.1#389
caugner wants to merge 4 commits intokewisch:masterfrom
caugner:187-support-vcard-2.1

Conversation

@caugner
Copy link
Copy Markdown
Contributor

@caugner caugner commented Apr 5, 2019

Fixes #187.

  • [1] Support QUOTED-PRINTABLE inline encoding [cf. Section 2.1.2].
  • [2] Do not interpret "\n" or "\N" as a CRLF(but instead literally as "\", followed by "n" or "N").
  • [3] Do not interpret COMMA as a multi-value separator [all values are single values].
  • [3] Note: Despite what vCard 3.0 states, a SEMICOLON must also be backslash escaped in vCard 2.1. "in a component of a compound property" [cf. Section 2.1.3]
  • [4] Require VERSION to be "2.1" [cf. Section 2.6.6].
  • [5] [6] n/a
  • [7] Support CHARSET type parameter [and default to ASCII, cf. 2.1.6].
  • [8] Support non-significant WSP characters [i.e. HTAB, cf. 2.9].
  • [9] Don't require parameter name, if the value is unambiguous [e.g. for TYPE= and ENCODING=, cf. 2.1.2].
  • [10] Require TYPE of LOGO [cf. 2.5.3.1], PHOTO [cf. 2.2.3.1] and SOUND [cf. 2.6.3.1] as defined by the spec [e.g. GIF].
  • [11] Parse inline binary content according to ENCODING parameter [and default to 7-bit, cf. 2.1.5].
  • [12] Do not support the PCS type parameter value for TEL [from vCard 3.0].
  • [13] Do not support CATEGORIES, CLASS, NICKNAME, PRODID and SORT-STRING [from vCard 3.0].
  • [14] Do not require N and FN [Note: N is only required for writers, not for readers, cf. 2.2.2].
  • [14] Note: Despite what vCard 3.0 states, VERSION is also required in vCard 2.1 [cf. [4] and 2.6.6].
  • [...] Use COMMA to separate GEO values [cf. 2.4.6 versus SEMICOLON in vCard 3.0]
  • [MR] Add tests.
  • [MR] Fix test coverage.

@skjnldsv
Copy link
Copy Markdown

skjnldsv commented Apr 5, 2019

Awesome!! @caugner
Let me know if I can be any help!

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 6, 2019

Coverage Status

Coverage decreased (-0.2%) to 96.764% when pulling 23a1d4a on caugner:187-support-vcard-2.1 into 2b4e50d on mozilla-comm:master.

@tasn
Copy link
Copy Markdown

tasn commented Jul 16, 2019

Glad to see you are working on it, life saver!

I tried testing it, but am getting "unsupported vCard version" with a vCard 4.0. Taking a brief look at the code, it look like your switch statement only handles 3.0 and 2.1 (though it could be intentional in that specific spot).

@caugner
Copy link
Copy Markdown
Contributor Author

caugner commented Jul 21, 2019

@tasn Can you share the vCard 4.0 which triggered the error? It sounds as if the vCard combines properties of vCard 3 and 4, because this switch statement should only be evaluated for vCards other than 4.0: !(name === 'version' && value === '4.0')

Comment thread lib/ical/parse.js
);
}

var debug = line.includes("37.386013");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var debug = line.includes("37.386013");

@tasn
Copy link
Copy Markdown

tasn commented Jul 21, 2019

Apologies for the noise!
I just checked following your comment and it seems that the failing one is a purposefully malformed entry I created. Interesting that none of the other clients (ez-vcard, python-vobject) fail when they get to it.

I guess you can ignore my comment. The entry for reference:

BEGIN:VCARD
PRODID;VALUE=TEXT:-//iCal.js EteSync Web
VERSION:4.0
UID:0561483d-251d-44e7-bb63-0cfd6285ffe3
FN:This contact checks broken vcard version
REV;VALUE=DATE-TIME:20190503T091907
IMPP;TYPE=jabber:jabber:
END:VCARD

@stefan123t
Copy link
Copy Markdown

regarding [1] there are two old issues at nextcloud contacts & server with some example ENCODING=QUOTED-PRINTABLE characters of danish and german users in case you want to extend your test case vcard21.vcf

nextcloud/contacts#584
nextcloud/server#10653

@kewisch kewisch deleted the branch kewisch:master December 5, 2021 13:41
@kewisch kewisch closed this Dec 5, 2021
@tasn
Copy link
Copy Markdown

tasn commented Dec 6, 2021

I guess this was accidentally closed because of the deletion of master?

NickCrews pushed a commit to NickCrews/ical.js that referenced this pull request Dec 1, 2025
This commit adds full support for parsing vCard 2.1 format, based on the
work from PR kewisch#389. Key features implemented:

- New vcard21 design set with proper text escaping rules
- Text type that escapes backslash, semicolon, and comma but does not
  treat commas as multi-value separators (vCard 2.1 uses single values)
- Support for vCard 2.1 specific parameters (encoding, charset)
- Version detection logic to automatically switch to vcard21 parser when
  VERSION:2.1 is encountered
- Comprehensive test coverage with vcard21.vcf and vcard21.json fixtures
- All existing tests continue to pass

The implementation correctly handles the key differences between vCard 2.1
and later versions:
- Escape sequences: only backslash, semicolon, and comma need escaping
- No comma-separated multi-value properties
- Semicolons still used for structured values
- Support for BASE64 encoding parameter (instead of 'b')
@NickCrews NickCrews mentioned this pull request Dec 1, 2025
8 tasks
@NickCrews
Copy link
Copy Markdown

I am trying to revive this in #958 if anyone wants to help. Still quite rough and not ready for review, I will remove the WIP mark when it is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support VCard 2.1

7 participants