node-vcf
node-vcf copied to clipboard
Parameter value containing a colon ':' leads to incorrect parsing
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, ";", ":"
That is an odd error message, because the “:” character is a colon. The “;” character is a semi-colon!
Indeed @Zearin , updated bug report with correct terms :).