Skip to content

fix(activesync): read meeting requests with the Horde\Icalendar reader - #113

Merged
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/meeting-request-icalendar-reader
Nov 2, 2026
Merged

ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/meeting-request-icalendar-reader

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Read incoming iTips with the typed Horde\Icalendar model instead of the legacy Horde_Icalendar property bag, so a repeated or multi-valued METHOD can no longer crash the sync.
  • Add a calendar time resolver that understands Windows and custom TZIDs through the calendar's own VTIMEZONE.
  • Mail with an unusable iTip degrades to a plain message instead of stalling the folder.

Fixes #112 (option C, as agreed with @ralflang).

Motivation

A text/calendar part with two METHOD lines made Horde_Icalendar::getAttributeDefault() return an array. HordeString::upper() then raised a TypeError in EasMessageBuilder::_meetingRequest(). A TypeError is not a Horde_ActiveSync_Exception, so it reached Horde_ErrorHandler::fatal() (HTTP 500) and the same mail was retried on every sync. The legacy API returns string|array for any attribute, so the same class of bug applies to CLASS, STATUS, ORGANIZER, DTSTART and others.

Changes

  • EasMessageBuilder: parse with AbstractComponent::fromString(), read METHOD once (default REQUEST, Bug #12083), log a repeated METHOD at debug level. messageclass, contentclass and meetingrequest are set only after parsing succeeded. _getiTipStatus() takes the typed calendar and throws Horde_ActiveSync_Exception (it used to throw an uncaught Horde_Icalendar_Exception).
  • Message_MeetingRequest: new fromCalendar(VCalendar, ?CalendarMethod); _parsevEvent() works on the typed Vevent. Location is unescaped and decoded (quoted-printable/charset), an end time is derived from DURATION, and the all-day check no longer breaks without an end time. fromvEvent() and getvEvent() stay as @deprecated adapters because the core driver and Kronolith's updateAttendee() still need the legacy vEvent.
  • Utils_Recurrence: detectInstanceType() / recurrenceFromVevent() take the typed Vevent (and an explicit start date). Their only caller is MeetingRequest.
  • New src/Calendar/:
    • CalendarTimeResolver: Z values, then the calendar's VTIMEZONE, then IANA/Windows names (TimezoneMapper), then the server time zone with a notice. Needed because Vevent::getDtstart() throws on non-IANA TZIDs.
    • VtimezoneOffsets: evaluates the UTC offset of a VTIMEZONE (yearly BYMONTH+BYDAY rules, RDATE, single observances, expired rules). Anything else returns null, so the resolver falls back instead of guessing.
    • ResolvedTime: value object.

Exceptions caught

Catch Where Handler
IcalendarException (interface) EasMessageBuilder::_meetingRequest() log err, deliver the mail without meeting data
Horde_ActiveSync_Exception same log err, deliver the mail without meeting data
Horde\Date\DateException MeetingRequest::_parsevEvent() unparseable DURATION / alarm TRIGGER is ignored, notice
Horde_Icalendar_Exception MeetingRequest::getvEvent() return null (legacy adapter)

No TypeError, ValueError or bare Exception is caught.

Behaviour changes

  • The reader is strict: a calendar that is not terminated is treated as plain mail (the legacy parser was lenient).
  • CLASS and STATUS are matched case-insensitively; a repeated CLASS uses the first value.
  • Location no longer depends on DTEND parsing.
  • Failures degrade to plain mail instead of stalling the folder.
  • Not changed: reminder is still exported in seconds.

Test plan

  • vendor/bin/phpunit --bootstrap vendor/autoload.php test/unit/Horde/ActiveSync/Calendar/CalendarTimeResolverTest.php (22 tests)
  • .../Message/MeetingRequestTest.php (29 tests)
  • .../Imap/EasMessageBuilderMeetingRequestTest.php (13 tests, includes the repeated METHOD regression)
  • Parsed every iCalendar fixture of horde/icalendar through fromCalendar(): no Throwable other than Horde_ActiveSync_Exception.
  • VtimezoneOffsets compared with PHP's tz database for the IANA-named zones in those fixtures (2008-2030): identical except where a fixture defines its own rules, and the legacy resolver deviates the same way there.
  • Check with a real iOS/Outlook invitation on a test device.

A text/calendar part that repeated METHOD made the legacy Horde_Icalendar
reader return an array, so HordeString::upper() raised a TypeError in
EasMessageBuilder::_meetingRequest(). The error bypassed the exporter's
Horde_ActiveSync_Exception handling and ended the request with HTTP 500,
so the affected mail was retried on every sync.

Read the iTip with the typed Horde\Icalendar model instead:

- EasMessageBuilder reads METHOD once (default REQUEST, Bug #12083) and
  only attaches the meeting data after parsing succeeded. Unparseable
  calendars, events without a usable DTSTART and replies without
  ATTENDEE now leave the mail as a plain message instead of stalling
  the folder.
- Message_MeetingRequest gets fromCalendar(VCalendar, ?CalendarMethod).
  fromvEvent() and getvEvent() remain as deprecated adapters for the
  consumers that still take the legacy vEvent.
- Utils_Recurrence takes the typed Vevent and an explicit start date.
- New Horde\ActiveSync\Calendar\CalendarTimeResolver resolves DATE and
  DATE-TIME values. The typed Vevent accessors only accept IANA TZIDs
  and throw on the Windows or custom names Outlook and Exchange send, so
  the resolver uses the calendar's own VTIMEZONE first (evaluated by
  VtimezoneOffsets), then IANA/Windows names, and finally the server
  time zone with a notice.

Fixes #112
@github-actions

Copy link
Copy Markdown

🔍 CI Results

Overall: ❌ 12/12 lanes failed

TL;DR: ❌ Quality issues: PHP-CS-Fixer: 48 files.

Summary by PHP Version

PHP dev stable
8.1 ❌ ❌
8.2 ❌ ❌
8.3 ❌ ❌
8.4 ❌ ❌
8.5 ❌ ❌
8.6 ❌ ❌

Quality Metrics

  • PHPUnit: did not run (12 lanes exited non-zero with no test output) ❌
  • PHPStan: No errors found ✅ — 8 advisories at level 2
  • PHP-CS-Fixer: 48 unique files with issues (of 237 checked) ⚠️
❌ Failed Lanes

php8.1-dev

  • PHPUnit: 0 failures, 0 errors

php8.1-stable

  • PHPUnit: 0 failures, 0 errors

php8.2-dev

  • PHPUnit: 0 failures, 0 errors

php8.2-stable

  • PHPUnit: 0 failures, 0 errors

php8.3-dev

  • PHPUnit: 0 failures, 0 errors

php8.3-stable

  • PHPUnit: 0 failures, 0 errors

php8.4-dev

  • PHPUnit: 0 failures, 0 errors
  • PHP-CS-Fixer: 48 files with issues

php8.4-stable

  • PHPUnit: 0 failures, 0 errors

php8.5-dev

  • PHPUnit: 0 failures, 0 errors

php8.5-stable

  • PHPUnit: 0 failures, 0 errors

php8.6-dev

  • PHPUnit: 0 failures, 0 errors

php8.6-stable

  • PHPUnit: 0 failures, 0 errors

CI powered by horde-components • View full results

@TDannhauer
TDannhauer requested a review from ralflang October 30, 2026 20:13
@ralflang
ralflang merged commit bb92581 into FRAMEWORK_6_0 Nov 2, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync aborts when a calendar message repeats METHOD

2 participants