-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Stringification for Parameters with Multiple Values #460
Conversation
…orced quoting ({multiValueSeparateDQuote: true})
value = value.map(stringify._rfc6868Unescape); | ||
if (designSet.param[paramName].multiValueSeparateDQuote) { | ||
multiValue = '"' + multiValue + '"'; | ||
value = value.map(function(v) { return '"' + v + '"'; }); | ||
} | ||
value = value.map(stringify._rfc6868Unescape); | ||
value = value.map(stringify.propertyValue); | ||
value = stringify.multiValue(value, multiValue, "unknown", null, designSet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are iterating value
with map
up to three times here, I think it might make sense to reduce this to one iteration.
@@ -222,9 +224,13 @@ ICAL.stringify = (function() { | |||
(helpers.unescapedIndexOf(value, ';') === -1)) { | |||
|
|||
return value; | |||
} | |||
} else if (value.startsWith('"') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atfer return
there is no need for else
(in any language).
#555 is a different approach to the same problem. |
It looks like we haven't heard back on this issue, therefore we are closing this issue. If this problem persists in the latest version of ical.js, please re-open this issue. |
I am currently trying to solve a problem when synchronizing contacts between nextcloud and macOS Contacts. One part of the problem seems to be that parameters with multiple values are not serialized correctly by ICAL.stringify. A phone number with multiple types (e.g. "HOME" and "VOICE") is serialized as TEL;TYPE="HOME,VOICE:0815 1234", which seems to be wrong according to the specification (https://tools.ietf.org/html/rfc2426#section-4 -> param = param-name "=" param-value *("," param-value)). The correct serialization should be TEL;TYPE=HOME,VOICE:0815 1234 or TEL;TYPE="HOME","VOICE":0815 1234.
My changes slightly update the serialization process for exactly this type of parameters. I have also added some tests to illustrate my changes.
Another possibility to fix my problem at hand would be to update the parameter configuration for phone numbers in design.js but I think that my solution which addresses the underlying problem is more general and hopefully future-proof.
Please let me know if my fix has any flaws or needs some further discussion!