Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/__tests__/unit/calendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,52 @@ describe('fetchCalendars', () => {
expect(result).toHaveLength(1);
expect(result[0].displayName).toBe('Good');
});

it('should accept calendars when supported-calendar-component-set is missing', async () => {
// Some servers (e.g. Purelymail) violate RFC 4791 § 5.2.3 by not returning the
// supported-calendar-component-set property. The previous resourcetype filter has
// already confirmed these are calendar collections, so they should pass through.
mockedPropfind.mockResolvedValue([
Comment on lines +379 to +383
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name says "supported-calendar-component-set is missing" but the fixture also covers the "present but empty" case (supportedCalendarComponentSet: {}); consider renaming the test to mention both (e.g. "missing or empty") or splitting into two tests to make the intent explicit.

Copilot uses AI. Check for mistakes.
{
href: '/cal/empty-prop/',
ok: true,
status: 200,
statusText: 'OK',
props: {
displayname: 'Empty Prop',
resourcetype: { calendar: {}, collection: {} },
// Server returned <supported-calendar-component-set/> with no children
supportedCalendarComponentSet: {},
getctag: 'c1',
},
},
{
href: '/cal/missing-prop/',
ok: true,
status: 200,
statusText: 'OK',
props: {
displayname: 'Missing Prop',
resourcetype: { calendar: {}, collection: {} },
// Property entirely absent from the response
getctag: 'c2',
},
},
]);
mockedSupportedReportSet.mockResolvedValue([]);

const result = await fetchCalendars({
account: {
serverUrl: 'https://example.com/',
homeUrl: 'https://example.com/cal/',
rootUrl: 'https://example.com/',
accountType: 'caldav',
},
});

expect(result).toHaveLength(2);
expect(result.map((c) => c.displayName)).toEqual(['Empty Prop', 'Missing Prop']);
});
});

describe('fetchCalendarUserAddresses', () => {
Expand Down
11 changes: 9 additions & 2 deletions src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,16 @@ export const fetchCalendars = async (params?: {
res
.filter((r) => Object.keys(r.props?.resourcetype ?? {}).includes('calendar'))
.filter((rc) => {
// filter out none iCal format calendars.
// Filter out non-iCal calendars when components are declared. Some servers
// (e.g. Purelymail) omit `supported-calendar-component-set` despite RFC 4791
// § 5.2.3 requiring it. When no usable component names come back, fall back to
// accepting the calendar — the previous filter already established it's a
// `<calendar/>` resourcetype, so we have independent evidence it's a calendar.
const components = extractComponentNames(rc.props?.supportedCalendarComponentSet?.comp);
return components.some((c) => Object.values(ICALObjects).includes(c as ICALObjects));
return (
components.length === 0 ||
components.some((c) => Object.values(ICALObjects).includes(c as ICALObjects))
);
})
.map((rs) => {
// debug(`Found calendar ${rs.props?.displayname}`);
Expand Down
Loading