Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum.supported.desktop.version #41183

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ public function beforeHandler(RequestInterface $request) {
}

$minimumSupportedDesktopVersion = $this->config->getSystemValue('minimum.supported.desktop.version', '2.3.0');
$maximumSupportedDesktopVersion = $this->config->getSystemValueString('maximum.supported.desktop.version', '');
preg_match(IRequest::USER_AGENT_CLIENT_DESKTOP, $userAgent, $versionMatches);
if (isset($versionMatches[1]) &&
version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) {
version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1 ||
!empty($maximumSupportedDesktopVersion) &&
version_compare($versionMatches[1], $maximumSupportedDesktopVersion) === 1) {
Comment on lines +72 to +74
Copy link
Member

Choose a reason for hiding this comment

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

Mixing && and || is confusing, can you add parenthesis to isolate the checks?
Or regroup the checks into dedicated variables :)

You can also probably use a crazy versio number as maximum fallback, like

- $maximumSupportedDesktopVersion = $this->config->getSystemValueString('maximum.supported.desktop.version', '');
+ $maximumSupportedDesktopVersion = $this->config->getSystemValueString('maximum.supported.desktop.version', '99.99.99');

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it will be better with two different error messages if the client is too old or too new.
It will help for debugging and solve the missing parenthesis

Copy link
Member

Choose a reason for hiding this comment

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

Seconded! 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Same. Good otherwise.

throw new \Sabre\DAV\Exception\Forbidden('Unsupported client version.');
}
}
Expand Down
11 changes: 11 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,17 @@
*/
'minimum.supported.desktop.version' => '2.3.0',

/**
* The maximum Nextcloud desktop client version that will be allowed to sync with
* this server instance. All connections made from later clients will be denied
* by the server. Defaults to the maximum officially supported Nextcloud desktop
* client version at the time of release of this server version.
*
*
* Defaults to empty
*/
'maximum.supported.desktop.version' => '',

/**
* Option to allow local storage to contain symlinks.
* WARNING: Not recommended. This would make it possible for Nextcloud to access
Expand Down
Loading