summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Sutherland <git@ksuther.com>2022-01-22 10:03:12 -0600
committerAllen Winter <allen.winter@kdab.com>2022-01-22 14:27:03 -0500
commit90320c9b4383d6a766f493fd5b22779fd927d21a (patch)
treec567704ff538ff293b9e159b1536d99795d234b2
parenteb3ce9bc29912b087b5868414f3028f60a13cc9d (diff)
downloadlibical-git-90320c9b4383d6a766f493fd5b22779fd927d21a.tar.gz
icalcomponent_set_due wasn't removing TZID when the icaltimetype doesn't have a zone This would result in strings like "DUE;TZID=America/Chicago:20220122" where the TZID wouldn't get removed even though the type is a DATE
-rw-r--r--ReleaseNotes.txt1
-rw-r--r--src/libical/icalcomponent.c1
-rw-r--r--src/test/regression.c22
3 files changed, 24 insertions, 0 deletions
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index dc428b86..55d29556 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -4,6 +4,7 @@ Release Highlights
Version 3.0.14 (UNRELEASED):
----------------------------
* icalvalue: Reset non-UTC icaltimetype::zone on set
+ * Fix icalcomponent_set_due not removing TZID when necessary
Version 3.0.13 (17 January 2022):
---------------------------------
diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c
index dc085709..cef5df5d 100644
--- a/src/libical/icalcomponent.c
+++ b/src/libical/icalcomponent.c
@@ -2382,6 +2382,7 @@ void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v)
icalcomponent_add_property(inner, due_prop);
} else if (due_prop != 0) {
icalproperty_set_due(due_prop, v);
+ icalproperty_remove_parameter_by_kind(due_prop, ICAL_TZID_PARAMETER);
} else if (dur_prop != 0) {
struct icaltimetype start = icalcomponent_get_dtstart(inner);
diff --git a/src/test/regression.c b/src/test/regression.c
index f50717d5..0e25b121 100644
--- a/src/test/regression.c
+++ b/src/test/regression.c
@@ -4924,6 +4924,27 @@ test_icalvalue_resets_timezone_on_set(void)
icalerror_clear_errno();
}
+static void test_remove_tzid_from_due(void)
+{
+ icalproperty *due = icalproperty_vanew_due(icaltime_from_string("20220120T120000"), 0);
+ icalcomponent *c;
+
+ icalproperty_add_parameter(due, icalparameter_new_tzid("America/New_York"));
+
+ c = icalcomponent_vanew(
+ ICAL_VCALENDAR_COMPONENT,
+ icalcomponent_vanew(
+ ICAL_VTODO_COMPONENT,
+ due,
+ 0),
+ 0);
+
+ icalcomponent_set_due(c, icaltime_from_string("20220120"));
+ str_is("icalproperty_as_ical_string()", "DUE;VALUE=DATE:20220120\r\n", icalproperty_as_ical_string(icalcomponent_get_first_property(icalcomponent_get_inner(c), ICAL_DUE_PROPERTY)));
+
+ icalcomponent_free(c);
+}
+
int main(int argc, char *argv[])
{
#if !defined(HAVE_UNISTD_H)
@@ -5065,6 +5086,7 @@ int main(int argc, char *argv[])
test_run("Test VCC vCard parse", test_vcc_vcard_parse, do_test, do_header);
test_run("Test implicit DTEND and DURATION for VEVENT and VTODO", test_implicit_dtend_duration, do_test, do_header);
test_run("Test icalvalue resets timezone on set", test_icalvalue_resets_timezone_on_set, do_test, do_header);
+ test_run("Test removing TZID from DUE with icalcomponent_set_due", test_remove_tzid_from_due, do_test, do_header);
/** OPTIONAL TESTS go here... **/