fix(caldav): expand RRULE for recurring events
This commit is contained in:
@@ -69,3 +69,36 @@ func TestNormalizeTimeZonesLeavesUnknownAndIANAZonesAlone(t *testing.T) {
|
||||
t.Fatalf("expected data to be unchanged, got:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestNormalizeTimeZonesFixesVTIMEZONECRLFLine reproduces a real bug: the
|
||||
// standalone "TZID:<name>" property line inside a VTIMEZONE component
|
||||
// (as opposed to a "TZID=<name>" parameter on DTSTART/DTEND/etc.) was
|
||||
// never being normalized on real-world feeds, because every
|
||||
// Outlook/Exchange-published ICS uses CRLF line endings and Go's RE2 "$"
|
||||
// anchor in multi-line mode only matches immediately before a literal
|
||||
// "\n" — not before "\r\n". So on a line like
|
||||
// "TZID:W. Europe Standard Time\r\n", the old
|
||||
// `^TZID:([^\r\n]+)$` pattern never matched at all, leaving the
|
||||
// VTIMEZONE's own declared TZID un-normalized while every "TZID=..."
|
||||
// parameter elsewhere in the same object WAS normalized (that regex has
|
||||
// no such issue) — so nothing referencing the VTIMEZONE by name could
|
||||
// ever find it again. See internal/icssub.Series.referencedTimezones,
|
||||
// which depends on exactly this match to embed the right VTIMEZONE in a
|
||||
// synthetic per-series VCALENDAR.
|
||||
func TestNormalizeTimeZonesFixesVTIMEZONECRLFLine(t *testing.T) {
|
||||
const raw = "BEGIN:VCALENDAR\r\n" +
|
||||
"BEGIN:VTIMEZONE\r\n" +
|
||||
"TZID:W. Europe Standard Time\r\n" +
|
||||
"END:VTIMEZONE\r\n" +
|
||||
"END:VCALENDAR\r\n"
|
||||
const want = "BEGIN:VCALENDAR\r\n" +
|
||||
"BEGIN:VTIMEZONE\r\n" +
|
||||
"TZID:Europe/Berlin\r\n" +
|
||||
"END:VTIMEZONE\r\n" +
|
||||
"END:VCALENDAR\r\n"
|
||||
|
||||
got := string(NormalizeTimeZones([]byte(raw)))
|
||||
if got != want {
|
||||
t.Fatalf("CRLF-terminated VTIMEZONE TZID line was not normalized:\ngot: %q\nwant: %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user