Skip to content

Commit 10f02e7

Browse files
skjnldsvmiaulalala
authored andcommitted
Force disabling single-quote list for type parameter
Signed-off-by: John Molakvoæ <[email protected]>
1 parent 83362c9 commit 10f02e7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/models/contact.js

+5
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,9 @@ export default class Contact {
566566
}
567567
}
568568

569+
toStringStripQuotes() {
570+
const regexp = /TYPE="([a-zA-Z-,]+)"/gm
571+
const card = this.vCard.toString()
572+
return card.replaceAll(regexp, 'TYPE=$1')
573+
}
569574
}

src/services/updateDesignSet.js

+25
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ const addGroupedProperties = vCard => {
6363
return madeChanges
6464
}
6565

66+
/**
67+
* Fixes misbehaviour with TYPE quotes and separated commas
68+
* Seems to have been introduced with https://github.com/mozilla-comm/ical.js/pull/387
69+
*
70+
* @returns {Boolean} Whether or not the design set has been altered.
71+
*/
72+
const setTypeMultiValueSeparateDQuote = () => {
73+
if (
74+
!ICAL.design.vcard.param.type
75+
|| ICAL.design.vcard.param.type.multiValueSeparateDQuote !== false
76+
|| !ICAL.design.vcard3.param.type
77+
|| ICAL.design.vcard3.param.type.multiValueSeparateDQuote !== false
78+
) {
79+
// https://github.com/mozilla-comm/ical.js/blob/ba8e2522ffd30ffbe65197a96a487689d6e6e9a1/lib/ical/stringify.js#L121
80+
ICAL.design.vcard.param.type.multiValueSeparateDQuote = false
81+
ICAL.design.vcard3.param.type.multiValueSeparateDQuote = false
82+
83+
return true
84+
}
85+
86+
return false
87+
}
88+
89+
/**
6690
/**
6791
* Check whether the ical.js design sets need updating (and if so, do it)
6892
*
@@ -72,6 +96,7 @@ const addGroupedProperties = vCard => {
7296
export default function(vCard) {
7397
let madeChanges = false
7498

99+
madeChanges |= setTypeMultiValueSeparateDQuote()
75100
madeChanges |= removePhoneNumberValueType()
76101
madeChanges |= addGroupedProperties(vCard)
77102

src/store/contacts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ const actions = {
353353
rev.fromUnixTime(Date.now() / 1000)
354354
contact.rev = rev
355355

356-
const vData = contact.vCard.toString()
356+
const vData = contact.toStringStripQuotes()
357357

358358
// if no dav key, contact does not exists on server
359359
if (!contact.dav) {

0 commit comments

Comments
 (0)