Force disabling single-quote list for type parameter

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2022-02-04 15:24:28 +01:00 committed by John Molakvoæ (Rebase PR Action)
parent 67a9da359e
commit 026ef7e01b
3 changed files with 31 additions and 1 deletions

View File

@ -566,4 +566,9 @@ export default class Contact {
}
}
toStringStripQuotes() {
const regexp = /TYPE="([a-zA-Z-,]+)"/gm
const card = this.vCard.toString()
return card.replaceAll(regexp, 'TYPE=$1')
}
}

View File

@ -63,6 +63,30 @@ const addGroupedProperties = vCard => {
return madeChanges
}
/**
* Fixes misbehaviour with TYPE quotes and separated commas
* Seems to have been introduced with https://github.com/mozilla-comm/ical.js/pull/387
*
* @returns {Boolean} Whether or not the design set has been altered.
*/
const setTypeMultiValueSeparateDQuote = () => {
if (
!ICAL.design.vcard.param.type
|| ICAL.design.vcard.param.type.multiValueSeparateDQuote !== false
|| !ICAL.design.vcard3.param.type
|| ICAL.design.vcard3.param.type.multiValueSeparateDQuote !== false
) {
// https://github.com/mozilla-comm/ical.js/blob/ba8e2522ffd30ffbe65197a96a487689d6e6e9a1/lib/ical/stringify.js#L121
ICAL.design.vcard.param.type.multiValueSeparateDQuote = false
ICAL.design.vcard3.param.type.multiValueSeparateDQuote = false
return true
}
return false
}
/**
/**
* Check whether the ical.js design sets need updating (and if so, do it)
*
@ -72,6 +96,7 @@ const addGroupedProperties = vCard => {
export default function(vCard) {
let madeChanges = false
madeChanges |= setTypeMultiValueSeparateDQuote()
madeChanges |= removePhoneNumberValueType()
madeChanges |= addGroupedProperties(vCard)

View File

@ -353,7 +353,7 @@ const actions = {
rev.fromUnixTime(Date.now() / 1000)
contact.rev = rev
const vData = contact.vCard.toString()
const vData = contact.toStringStripQuotes()
// if no dav key, contact does not exists on server
if (!contact.dav) {