]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(settings): make trailing slash for caldav/carddav redirects optional 46093/head
authorMichaIng <micha@dietpi.com>
Mon, 24 Jun 2024 15:52:22 +0000 (17:52 +0200)
committerMichaIng <micha@dietpi.com>
Tue, 9 Jul 2024 22:24:39 +0000 (00:24 +0200)
#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 <micha@dietpi.com>
apps/settings/lib/SetupChecks/WellKnownUrls.php

index f30bf21769005529d211c3ec6a26a5d7c95c9597..9471867c866f6f2751e5d714ff226b8bd578a70e 100644 (file)
@@ -81,7 +81,7 @@ class WellKnownUrls implements ISetupCheck {
                                        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