-
Notifications
You must be signed in to change notification settings - Fork 138
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
Quote (or don't quote) property values individually before joining #555
Conversation
Pull Request Test Coverage Report for Build 3418295304
💛 - Coveralls |
Pull Request Test Coverage Report for Build 8427565049Details
💛 - Coveralls |
Aha, I thought I had asked about this before. I did, in #532. |
In the provided test cases:
the property values are Concerning the stringification of property parameter values and avoiding unnecessary quotes, I have a different approach — #535, for a different test-case. In I understand this is an open-source voluntary run project and I get what I paid for. Different users of ical.js submit corrections for inclusion upstream. Including the corrections upstream takes sometimes very, very long time. This results that different solutions to the same problem are submitted, while uploaded corrections are not merged upstream. I will appreciate if some process is suggested, that makes merging submitted changes, which include test cases, upstream more fluent. This will be in the common interest. I value the time invested in maintaining the project and personally I am not willing to be its maintainer. The only point I am raising is that it takes very long time between patch submission and its inclusion. So any speedup will be more than welcomed. |
Ah, this is not about multivalued property values, but about multivalued parameter values. Can you add a test/example, which produces this stringification result:
|
9b33f46
to
51ef34e
Compare
Yes, the names are confusing. I'd have changed the commit message with my recent push if only Github had notified me about your comments.
I'm not sure if that's valid. It's a question I've been wrestling with since I first tried to fix this bug. It looks like it should be valid, but I'm yet to find any concrete answer one way or the other. Maybe I'll just assume it is valid and move on. |
51ef34e
to
a550a9f
Compare
There. Added the extra bit to the test, which unsurprisingly was already working. I also renamed the function in question to be less confusing. |
https://www.rfc-editor.org/rfc/rfc6350#section-3.3 defines any-param = (iana-token / x-name) "=" param-value *("," param-value) QSAFE-CHAR = WSP / "!" / %x23-7E / NON-ASCII SAFE-CHAR = WSP / "!" / %x23-39 / %x3C-7E / NON-ASCII Comma (ascii code dec 44, %x2C) is SAFE-CHAR and QSAFE-CHARE, as it is within %x23-39 and within %x23-7E. I came now the conclusion that x-b,x-c as in I have created one more example: diff --git a/test/stringify_test.js b/test/stringify_test.js
index bc375b6..1ebd7c4 100644
--- a/test/stringify_test.js
+++ b/test/stringify_test.js
@@ -193,6 +193,14 @@ suite('ICAL.stringify', function() {
},
"phone-number",
"1234567"
+ ],
+ [
+ "x-a",
+ {
+ "x-B": "x-c^d,"
+ },
+ "text",
+ "Brum"
]
]
];
@@ -200,6 +208,7 @@ suite('ICAL.stringify', function() {
"BEGIN:VCARD\r\n" +
"ADR;TYPE=dom,home,postal,parcel:;;123 Main Street;Any Town;CA;91921-1234\r\n" +
"TEL;TYPE=home,voice,x-a,\"x-b,x-c\":1234567\r\n" +
+ "X-A;X-B=x-c^^d,;VALUE=TEXT:Brum\r\n" +
"END:VCARD";
assert.equal(ICAL.stringify.component(subject), expected);
}); This fails. The produced output is X-A;X-B="x-c^^d,";VALUE=TEXT:Brum but there is no need to quote, since
|
#460 is a different approach to the same problem. |
a550a9f
to
9819520
Compare
I took the tests from #460 since they're more comprehensive than mine, and fixed a failure they caught. |
let multiValue = (paramName in designSet.param) && designSet.param[paramName].multiValue; | ||
|
||
let paramDesign = designSet.param[paramName]; | ||
let multiValue = paramDesign && paramDesign.multiValue; |
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.
const multiValue = paramDesign?.multiValue;
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.
For me it is unclear, why the above suggestion was skipped.
The backslash is not escaping character in property parameters. When I modify one of the tests as: diff --git a/test/stringify_test.js b/test/stringify_test.js
index 40337b8..800fe19 100644
--- a/test/stringify_test.js
+++ b/test/stringify_test.js
@@ -84,9 +84,9 @@ suite('ICAL.stringify', function() {
ICAL.design.defaultSet.property.custom = { defaultType: 'text' };
ICAL.design.defaultSet.param.type = { multiValue: ',' };
let subject = new ICAL.Property('custom');
- subject.setParameter('type', ['ABC', 'XYZ']);
+ subject.setParameter('type', ['\\:ABC', 'XYZ']);
subject.setValue('some value');
- assert.equal(subject.toICALString(), 'CUSTOM;TYPE=ABC,XYZ:some value');
+ assert.equal(subject.toICALString(), 'CUSTOM;TYPE="\\:ABC",XYZ:some value');
delete ICAL.design.defaultSet.property.custom;
delete ICAL.design.defaultSet.param.type;
}); it fails:
#535 suggests to use |
…joining Instead of adding quotes to the delimiting comma and around the outside, quote the individual members separately if necessary. This prevents the whole string of multiple values being quoted because of the presence of a delimiting comma. When quotes are required (multiValueSeparateDQuote is true) only URIs are valid, which will get quoted due to the colon. When not required only specific strings (WORK, VOICE, PARCEL, etc.) are valid, none of which need quotes.
9819520
to
3aafb40
Compare
Rebased with no further changes. FWIW, we've been shipping these changes in Thunderbird since November 2022. It may not be perfect but I think we should merge as-is and open follow-up issues for outstanding problems. |
Sounds fine to me, thank you! |
As I mentioned above, this change is suboptimal. #658 does further improve encoding (quoting) of property parameter values. |
… as \ is no escape character there. When the propery parameter contains :, then it must be quoted, the colon cannot be escaped. As the function stringify.propertyValue in fact stringifies property parameter values, it is renamed accordingly. kewisch#658 This supersedes kewisch#535 and updates kewisch#555 . Without these changes, the herein added test fails: 1) ICAL.stringify stringify property stringify property value containing "escaped" ; , :: AssertionError: expected 'ATTENDEE;CN=X\::mailto:id' to equal 'ATTENDEE;CN="X\:":mailto:id' + expected - actual -ATTENDEE;CN=X\::mailto:id +ATTENDEE;CN="X\:":mailto:id
… as \ is no escape character there. When the propery parameter contains :, then it must be quoted, the colon cannot be escaped. As the function stringify.propertyValue in fact stringifies property parameter values, it is renamed accordingly. kewisch#658 This supersedes kewisch#535 and updates kewisch#555 . Without these changes, the herein added test fails: 1) ICAL.stringify stringify property stringify property value containing "escaped" ; , :: AssertionError: expected 'ATTENDEE;CN=X\::mailto:id' to equal 'ATTENDEE;CN="X\:":mailto:id' + expected - actual -ATTENDEE;CN=X\::mailto:id +ATTENDEE;CN="X\:":mailto:id
Instead of adding quotes to the delimiting comma and around the outside, quote the individual members separately if necessary. This prevents the whole string of multiple values being quoted because of the presence of a delimiting comma.
When quotes are required (multiValueSeparateDQuote is true) only URIs are valid, which will get quoted due to the colon. When not required only specific strings (WORK, VOICE, PARCEL, etc.) are valid, none of which need quotes.