Skip to content

Commit 23facaa

Browse files
Merge pull request #54584 from nextcloud/backport/54575/stable30
[stable30] fix: use appropriate user agent string when syncing Outlook calendar subscriptions
2 parents e749047 + c74198b commit 23facaa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/dav/lib/CalDAV/WebcalCaching/Connection.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,24 @@ public function queryWebcalFeed(array $subscription): ?string {
3232
return null;
3333
}
3434

35+
// ICS feeds hosted on O365 can return HTTP 500 when the UA string isn't satisfactory
36+
// Ref https://github.com/nextcloud/calendar/issues/7234
37+
$uaString = 'Nextcloud Webcal Service';
38+
if (parse_url($url, PHP_URL_HOST) === 'outlook.office365.com') {
39+
// The required format/values here are not documented.
40+
// Instead, this string based on research.
41+
// Ref https://github.com/bitfireAT/icsx5/discussions/654#discussioncomment-14158051
42+
$uaString = 'Nextcloud (Linux) Chrome/66';
43+
}
44+
3545
$allowLocalAccess = $this->config->getValueString('dav', 'webcalAllowLocalAccess', 'no');
3646

3747
$params = [
3848
'nextcloud' => [
3949
'allow_local_address' => $allowLocalAccess === 'yes',
4050
],
4151
RequestOptions::HEADERS => [
42-
'User-Agent' => 'Nextcloud Webcal Service',
52+
'User-Agent' => $uaString,
4353
'Accept' => 'text/calendar, application/calendar+json, application/calendar+xml',
4454
],
4555
];

0 commit comments

Comments
 (0)