Skip to content
Open
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion apps/dav/lib/CalDAV/WebcalCaching/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public function __construct(
) {
}

/**
* look for ics feeds hosted on O365 servers. These can be picky about UA string
*/
private static function isO365Url($url) {
$host = parse_url($url, PHP_URL_HOST);
return $host === 'outlook.office365.com';
}

/**
* gets webcal feed from remote server
*/
Expand All @@ -34,14 +42,22 @@ public function queryWebcalFeed(array $subscription): ?string {
return null;
}

// calendar/#7234 - ICS feeds hosted on O365 can return HTTP 500 when the UA string isn't satisfactory..
$uaString = 'Nextcloud Webcal Service';
if (isO365Url($url)) {
// 2025/08/20 - the required format/values here are not documented; this string based on research
// from: https://github.com/bitfireAT/icsx5/discussions/654#discussioncomment-14158051
$uaString = 'NextCloud/30.x (Linux Android 16) like Chrome/30';

Choose a reason for hiding this comment

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

Is a number for the Nextcloud version required or does it work without it? If it's required, it would be more appropriate to provide the actual Nextcloud version.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It turns out Nextcloud Version is not required. The easiest thing is to omit it.

If there is a method which holds the version string and is easy to plumb in here, I could Include it. Do you know of something appropriate?

Choose a reason for hiding this comment

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

There's a OCP\ServerVersion class that provides all that you need, but I think you shouldn't include if it's not required.

}

$allowLocalAccess = $this->config->getValueString('dav', 'webcalAllowLocalAccess', 'no');

$params = [
'nextcloud' => [
'allow_local_address' => $allowLocalAccess === 'yes',
],
RequestOptions::HEADERS => [
'User-Agent' => 'Nextcloud Webcal Service',
'User-Agent' => $uaString,
'Accept' => 'text/calendar, application/calendar+json, application/calendar+xml',
],
];
Expand Down