@@ -21,54 +21,54 @@ |
||
21 | 21 | * @package OCA\DAV\Connector\Sabre |
22 | 22 | */ |
23 | 23 | class BlockLegacyClientPlugin extends ServerPlugin { |
24 | - protected ?Server $server = null; |
|
24 | + protected ?Server $server = null; |
|
25 | 25 | |
26 | - public function __construct( |
|
27 | - private IConfig $config, |
|
28 | - private ThemingDefaults $themingDefaults, |
|
29 | - ) { |
|
30 | - } |
|
26 | + public function __construct( |
|
27 | + private IConfig $config, |
|
28 | + private ThemingDefaults $themingDefaults, |
|
29 | + ) { |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public function initialize(Server $server) { |
|
36 | - $this->server = $server; |
|
37 | - $this->server->on('beforeMethod:*', [$this, 'beforeHandler'], 200); |
|
38 | - } |
|
32 | + /** |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public function initialize(Server $server) { |
|
36 | + $this->server = $server; |
|
37 | + $this->server->on('beforeMethod:*', [$this, 'beforeHandler'], 200); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Detects all unsupported clients and throws a \Sabre\DAV\Exception\Forbidden |
|
42 | - * exception which will result in a 403 to them. |
|
43 | - * @param RequestInterface $request |
|
44 | - * @throws \Sabre\DAV\Exception\Forbidden If the client version is not supported |
|
45 | - */ |
|
46 | - public function beforeHandler(RequestInterface $request) { |
|
47 | - $userAgent = $request->getHeader('User-Agent'); |
|
48 | - if ($userAgent === null) { |
|
49 | - return; |
|
50 | - } |
|
40 | + /** |
|
41 | + * Detects all unsupported clients and throws a \Sabre\DAV\Exception\Forbidden |
|
42 | + * exception which will result in a 403 to them. |
|
43 | + * @param RequestInterface $request |
|
44 | + * @throws \Sabre\DAV\Exception\Forbidden If the client version is not supported |
|
45 | + */ |
|
46 | + public function beforeHandler(RequestInterface $request) { |
|
47 | + $userAgent = $request->getHeader('User-Agent'); |
|
48 | + if ($userAgent === null) { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - $minimumSupportedDesktopVersion = $this->config->getSystemValueString('minimum.supported.desktop.version', '3.1.0'); |
|
53 | - $maximumSupportedDesktopVersion = $this->config->getSystemValueString('maximum.supported.desktop.version', '99.99.99'); |
|
52 | + $minimumSupportedDesktopVersion = $this->config->getSystemValueString('minimum.supported.desktop.version', '3.1.0'); |
|
53 | + $maximumSupportedDesktopVersion = $this->config->getSystemValueString('maximum.supported.desktop.version', '99.99.99'); |
|
54 | 54 | |
55 | - // Check if the client is a desktop client |
|
56 | - preg_match(IRequest::USER_AGENT_CLIENT_DESKTOP, $userAgent, $versionMatches); |
|
55 | + // Check if the client is a desktop client |
|
56 | + preg_match(IRequest::USER_AGENT_CLIENT_DESKTOP, $userAgent, $versionMatches); |
|
57 | 57 | |
58 | - // If the client is a desktop client and the version is too old, block it |
|
59 | - if (isset($versionMatches[1]) && version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) { |
|
60 | - $customClientDesktopLink = htmlspecialchars($this->themingDefaults->getSyncClientUrl()); |
|
61 | - $minimumSupportedDesktopVersion = htmlspecialchars($minimumSupportedDesktopVersion); |
|
58 | + // If the client is a desktop client and the version is too old, block it |
|
59 | + if (isset($versionMatches[1]) && version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) { |
|
60 | + $customClientDesktopLink = htmlspecialchars($this->themingDefaults->getSyncClientUrl()); |
|
61 | + $minimumSupportedDesktopVersion = htmlspecialchars($minimumSupportedDesktopVersion); |
|
62 | 62 | |
63 | - throw new \Sabre\DAV\Exception\Forbidden("This version of the client is unsupported. Upgrade to <a href=\"$customClientDesktopLink\">version $minimumSupportedDesktopVersion or later</a>."); |
|
64 | - } |
|
63 | + throw new \Sabre\DAV\Exception\Forbidden("This version of the client is unsupported. Upgrade to <a href=\"$customClientDesktopLink\">version $minimumSupportedDesktopVersion or later</a>."); |
|
64 | + } |
|
65 | 65 | |
66 | - // If the client is a desktop client and the version is too new, block it |
|
67 | - if (isset($versionMatches[1]) && version_compare($versionMatches[1], $maximumSupportedDesktopVersion) === 1) { |
|
68 | - $customClientDesktopLink = htmlspecialchars($this->themingDefaults->getSyncClientUrl()); |
|
69 | - $maximumSupportedDesktopVersion = htmlspecialchars($maximumSupportedDesktopVersion); |
|
66 | + // If the client is a desktop client and the version is too new, block it |
|
67 | + if (isset($versionMatches[1]) && version_compare($versionMatches[1], $maximumSupportedDesktopVersion) === 1) { |
|
68 | + $customClientDesktopLink = htmlspecialchars($this->themingDefaults->getSyncClientUrl()); |
|
69 | + $maximumSupportedDesktopVersion = htmlspecialchars($maximumSupportedDesktopVersion); |
|
70 | 70 | |
71 | - throw new \Sabre\DAV\Exception\Forbidden("This version of the client is unsupported. Downgrade to <a href=\"$customClientDesktopLink\">version $maximumSupportedDesktopVersion or earlier</a>."); |
|
72 | - } |
|
73 | - } |
|
71 | + throw new \Sabre\DAV\Exception\Forbidden("This version of the client is unsupported. Downgrade to <a href=\"$customClientDesktopLink\">version $maximumSupportedDesktopVersion or earlier</a>."); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |