Fix: create_calendar_event silently fails for timezone offsets#45
Closed
JonathanGodley wants to merge 1 commit into
Closed
Fix: create_calendar_event silently fails for timezone offsets#45JonathanGodley wants to merge 1 commit into
JonathanGodley wants to merge 1 commit into
Conversation
The CalDAV PUT is silently rejected because timezone offsets are mangled by the naive replace(/[-:]/g, '') — e.g. +10:00 becomes +1000, which is not a valid iCal datetime form. Events appear to create successfully but are never persisted. Add toICalUTC() that converts offset datetimes to UTC and preserves floating times. Add foldICalLine() that folds at 75 UTF-8 octets per RFC 5545 §3.1, with surrogate pair safety. Fix unescapeICalText() ordering bug by switching to single-pass regex (sequential .replace() incorrectly decoded \n as newline instead of literal backslash + n).
7 tasks
Owner
|
Closing as superseded: the timezone-offset silent failure was fixed in v1.9.3 (validateAndFormatICalDate normalizes offsets to UTC), the unescapeICalText ordering bug landed via PR #81 in v1.9.5, and RFC 5545 §3.1 line folding shipped with the PR #53 calendar overhaul in v1.11.0. All three of this PR's fixes are now on main — thanks for the thorough diagnosis, it drove each of them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_calendar_eventreturns a success response with a UID, but the event is never persisted on the CalDAV server when the input datetime includes a timezone offset (e.g.+10:00). No error is thrown.Root cause: The naive
event.start.replace(/[-:]/g, '')strips colons from timezone offsets, producingDTSTART:20260407T184500+1000— which is not a valid iCalendar datetime form (RFC 5545 §3.3.5 requires UTC withZ, floating, orTZIDparameter). The server silently rejects the PUT whiletsdavdoes not throw.This PR also fixes two related iCalendar encoding issues:
unescapeICalTextordering bug: The sequential.replace()chain incorrectly decodes\n(escaped backslash + letter n) as a newline instead of\n. This is an interop issue — it corrupts text when parsing events created by other CalDAV clients (Apple Calendar, Thunderbird, etc.) that correctly escape literal backslashes per RFC 5545 §3.3.11Changes
toICalUTC()— converts ISO 8601 offset datetimes to UTC, preserves floating timesfoldICalLine()— folds content lines at 75 UTF-8 octets with surrogate pair safetyunescapeICalText()— single-pass regex avoids ordering ambiguity between\and\ncreateCalendarEventto usetoICalUTCandfoldICalLineTest plan
toICalUTC(positive/negative offsets, UTC, floating, invalid input, boundary crossing)foldICalLine(short passthrough, basic fold, multi-segment, 75-octet enforcement, multi-byte emoji)unescapeICalText(basic unescaping, round-trip withescapeICalText,\nand\,edge cases)