node-vcf icon indicating copy to clipboard operation
node-vcf copied to clipboard

Parameter value containing a colon ':' leads to incorrect parsing

Open adaxi opened this issue 5 years ago • 2 comments
trafficstars

Here is a small snippet which allows to reproduce the issue:

const Vcf = require('vcf')
const data = `BEGIN:VCARD
VERSION:4.0
NAME;PARAMETER="parameter value contains a :colon":value also contains a :colon
END:VCARD`.replace(/\n/g, '\r\n')

const vCard = new Vcf().parse(data)

console.log(vCard.get('name').valueOf())

This returns:

colon":value also contains a :colon

instead of:

value also contains a :colon

According to the RFC, the colon is allowed in the parameter value as long as its within double quotes.

   param-value = *SAFE-CHAR / DQUOTE *QSAFE-CHAR DQUOTE

   any-param  = (iana-token / x-name) "=" param-value *("," param-value)

   NON-ASCII = UTF8-2 / UTF8-3 / UTF8-4
     ; UTF8-{2,3,4} are defined in [RFC3629]

   QSAFE-CHAR = WSP / "!" / %x23-7E / NON-ASCII
     ; Any character except CTLs, DQUOTE

   SAFE-CHAR = WSP / "!" / %x23-39 / %x3C-7E / NON-ASCII
     ; Any character except CTLs, DQUOTE, ";", ":"

adaxi avatar Jan 06 '20 14:01 adaxi

That is an odd error message, because the “:” character is a colon. The “;” character is a semi-colon!

Zearin avatar Jul 04 '22 15:07 Zearin

Indeed @Zearin , updated bug report with correct terms :).

adaxi avatar Jul 04 '22 19:07 adaxi