Skip to content

Commit

Permalink
Make sure we don't include 'VALUE=PHONE-NUMBER' to avoid a bug in sab…
Browse files Browse the repository at this point in the history
…re-io/vobject

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>
  • Loading branch information
hanzi committed Jan 6, 2020
1 parent 16001ab commit b9f63e6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/services/updateDesignSet.js
Expand Up @@ -48,6 +48,24 @@ const setLabelAsSingleValue = () => {
return false
}

/**
* Prevents ical.js from adding 'VALUE=PHONE-NUMBER' in vCard 3.0.
* While not wrong according to the RFC, there's a bug in sabreio/vobject (used
* by Nextcloud Server) that prevents saving vCards with this parameters.
*
* @link https://github.com/nextcloud/contacts/pull/1393#issuecomment-570945735
*
* @returns {Boolean} Whether or not the design set has been altered.
*/
const removePhoneNumberValueType = () => {
if (ICAL.design.vcard3.property.tel) {
delete ICAL.design.vcard3.property.tel
return true
}

return false
}

/**
* Some clients group properties by naming them something like 'ITEM1.URL'.
* These should be treated the same as their original (i.e. 'URL' in this
Expand Down Expand Up @@ -82,6 +100,7 @@ export default function(vCard) {
let madeChanges = false

madeChanges |= setLabelAsSingleValue()
madeChanges |= removePhoneNumberValueType()
madeChanges |= addGroupedProperties(vCard)

return madeChanges
Expand Down

0 comments on commit b9f63e6

Please sign in to comment.