diff options
author | Robert Stepanek <rsto@fastmailteam.com> | 2022-10-25 15:32:17 +0200 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2022-10-25 15:31:06 -0400 |
commit | 359fff600e5793b5170f712643b484fb1313ec43 (patch) | |
tree | 8dc9235cd1e0200d08c20220853df46e50b5b43a /src | |
parent | 02a54aa6f926836fe88a0a4a769116960082f410 (diff) | |
download | libical-git-359fff600e5793b5170f712643b484fb1313ec43.tar.gz |
Escape comma in x-property TEXT values
453689b7678cbc588c2811efb953d513fc8dc90f changed libical
to not escape comma in x-property values. While this is
a sane choice for x-property values of unknown kind, it
is wrong if the value type of the property is TEXT.
Diffstat (limited to 'src')
-rw-r--r-- | src/libical/icalvalue.c | 3 | ||||
-rw-r--r-- | src/test/regression.c | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c index c18fad02..01212ae3 100644 --- a/src/libical/icalvalue.c +++ b/src/libical/icalvalue.c @@ -307,7 +307,8 @@ static char *icalmemory_strdup_and_quote(const icalvalue *value, const char *unq if ((icalproperty_isa(value->parent) == ICAL_CATEGORIES_PROPERTY) || (icalproperty_isa(value->parent) == ICAL_RESOURCES_PROPERTY) || (icalproperty_isa(value->parent) == ICAL_POLLPROPERTIES_PROPERTY) || - (icalproperty_isa(value->parent) == ICAL_X_PROPERTY)) { + ((icalproperty_isa(value->parent) == ICAL_X_PROPERTY) && + icalvalue_isa(value) != ICAL_TEXT_VALUE)) { icalmemory_append_char(&str, &str_p, &buf_sz, *p); break; } diff --git a/src/test/regression.c b/src/test/regression.c index 1e5a0acb..36a49961 100644 --- a/src/test/regression.c +++ b/src/test/regression.c @@ -4921,6 +4921,7 @@ test_icalvalue_resets_timezone_on_set(void) static void test_comma_in_xproperty(void) { + // X-property value without explicit value type icalproperty *xproperty = icalproperty_new_from_string("X-TEST-PROPERTY:test,test"); icalcomponent *c; @@ -4935,6 +4936,21 @@ static void test_comma_in_xproperty(void) str_is("icalproperty_as_ical_string()", "X-TEST-PROPERTY:test,test\r\n", icalproperty_as_ical_string(icalcomponent_get_first_property(icalcomponent_get_inner(c), ICAL_X_PROPERTY))); icalcomponent_free(c); + + // X-property value with TEXT value type + xproperty = icalproperty_new_from_string("X-TEST-PROPERTY;VALUE=TEXT:test\\,test"); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + xproperty, + 0), + 0); + + str_is("icalproperty_as_ical_string()", "X-TEST-PROPERTY;VALUE=TEXT:test\\,test\r\n", icalproperty_as_ical_string(icalcomponent_get_first_property(icalcomponent_get_inner(c), ICAL_X_PROPERTY))); + + icalcomponent_free(c); } static void test_remove_tzid_from_due(void) |