From 79bcb9d3de4c88e1235d1888388b562f6d950e77 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Mon, 24 Jun 2024 17:52:22 +0200 Subject: [PATCH] fix(settings): make trailing slash for caldav/carddav redirects optional #43939 moved the CalDAV/CardDAV redirect checks from the frontend to a new backend API. Since the backend does not send an authentication header, checking for the expected response code 207 of the DAV endpoint does not work anymore, hence the URL of the last redirect is checked instead. This URL is expected to contain a trailing slash, which was not required before, since the DAV endpoint works properly without it (when authenticated). While a trailing slash in the redirect does no harm, it causes many setups to throw an admin panel warning, while in fact the redirects work properly. Furthermore, the proposed "/.well-known/carddav" => "/remote.php/dav/" redirect leads to double slashes, when doing a request to "/.well-known/carddav/", which seems more wrong then right. This change makes the trailing slash optional, hence old and adjusted setups won't throw the warning anymore, and the DAV endpoint works well in both cases. Signed-off-by: MichaIng --- apps/settings/lib/SetupChecks/WellKnownUrls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/settings/lib/SetupChecks/WellKnownUrls.php b/apps/settings/lib/SetupChecks/WellKnownUrls.php index f30bf21769005..9471867c866f6 100644 --- a/apps/settings/lib/SetupChecks/WellKnownUrls.php +++ b/apps/settings/lib/SetupChecks/WellKnownUrls.php @@ -81,7 +81,7 @@ public function run(): SetupResult { if (!$works && $response->getStatusCode() === 401) { $redirectHops = explode(',', $response->getHeader('X-Guzzle-Redirect-History')); $effectiveUri = end($redirectHops); - $works = str_ends_with($effectiveUri, '/remote.php/dav/'); + $works = str_ends_with(rtrim($effectiveUri, '/'), '/remote.php/dav'); } } // Skip the other requests if one works