Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

zlajo
Copy link

@zlajo zlajo commented Dec 30, 2020

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!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 96.993% when pulling 0f47187 on zlajo:master into dcfe5a6 on mozilla-comm:master.

Comment on lines +121 to 126
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);
Copy link
Owner

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.

@kewisch kewisch added the needinfo More information has been requested label Jul 13, 2021
@@ -222,9 +224,13 @@ ICAL.stringify = (function() {
(helpers.unescapedIndexOf(value, ';') === -1)) {

return value;
}
} else if (value.startsWith('"') &&
Copy link
Contributor

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).

@dilyanpalauzov
Copy link
Contributor

#555 is a different approach to the same problem.

Copy link

github-actions bot commented Apr 2, 2024

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.

@github-actions github-actions bot closed this Apr 2, 2024
@github-actions github-actions bot removed the needinfo More information has been requested label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants