diff options
Diffstat (limited to 'apps/dav/lib/Files')
-rw-r--r-- | apps/dav/lib/Files/BrowserErrorPagePlugin.php | 6 | ||||
-rw-r--r-- | apps/dav/lib/Files/FileSearchBackend.php | 8 | ||||
-rw-r--r-- | apps/dav/lib/Files/Sharing/FilesDropPlugin.php | 6 | ||||
-rw-r--r-- | apps/dav/lib/Files/Sharing/RootCollection.php | 32 |
4 files changed, 47 insertions, 5 deletions
diff --git a/apps/dav/lib/Files/BrowserErrorPagePlugin.php b/apps/dav/lib/Files/BrowserErrorPagePlugin.php index de86c4995e2..85ed975a409 100644 --- a/apps/dav/lib/Files/BrowserErrorPagePlugin.php +++ b/apps/dav/lib/Files/BrowserErrorPagePlugin.php @@ -11,6 +11,7 @@ use OC\AppFramework\Http\Request; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\TemplateResponse; use OCP\IRequest; +use OCP\Security\Bruteforce\MaxDelayReached; use OCP\Template\ITemplateManager; use Sabre\DAV\Exception; use Sabre\DAV\Server; @@ -60,6 +61,9 @@ class BrowserErrorPagePlugin extends ServerPlugin { if ($ex instanceof Exception) { $httpCode = $ex->getHTTPCode(); $headers = $ex->getHTTPHeaders($this->server); + } elseif ($ex instanceof MaxDelayReached) { + $httpCode = 429; + $headers = []; } else { $httpCode = 500; $headers = []; @@ -81,7 +85,7 @@ class BrowserErrorPagePlugin extends ServerPlugin { $request = \OCP\Server::get(IRequest::class); $templateName = 'exception'; - if ($httpCode === 403 || $httpCode === 404) { + if ($httpCode === 403 || $httpCode === 404 || $httpCode === 429) { $templateName = (string)$httpCode; } diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index 1b785962112..ace367e4490 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -422,10 +422,16 @@ class FileSearchBackend implements ISearchBackend { $field = $this->mapPropertyNameToColumn($property); } + try { + $castedValue = $this->castValue($property, $value ?? ''); + } catch (\Error $e) { + throw new \InvalidArgumentException('Invalid property value for ' . $property->name, previous: $e); + } + return new SearchComparison( $trimmedType, $field, - $this->castValue($property, $value ?? ''), + $castedValue, $extra ?? '' ); diff --git a/apps/dav/lib/Files/Sharing/FilesDropPlugin.php b/apps/dav/lib/Files/Sharing/FilesDropPlugin.php index 9d883be81fc..ccf7cd28f4a 100644 --- a/apps/dav/lib/Files/Sharing/FilesDropPlugin.php +++ b/apps/dav/lib/Files/Sharing/FilesDropPlugin.php @@ -73,7 +73,7 @@ class FilesDropPlugin extends ServerPlugin { if ($isFileRequest && ($nickName == null || trim($nickName) === '')) { throw new MethodNotAllowed('Nickname is required for file requests'); } - + // If this is a file request we need to create a folder for the user if ($isFileRequest) { // Check if the folder already exists @@ -83,9 +83,9 @@ class FilesDropPlugin extends ServerPlugin { // Put all files in the subfolder $path = $nickName . '/' . $path; } - + $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); - $url = $request->getBaseUrl() . $newName; + $url = $request->getBaseUrl() . '/files/' . $this->share->getToken() . $newName; $request->setUrl($url); } diff --git a/apps/dav/lib/Files/Sharing/RootCollection.php b/apps/dav/lib/Files/Sharing/RootCollection.php new file mode 100644 index 00000000000..dd585fbb59b --- /dev/null +++ b/apps/dav/lib/Files/Sharing/RootCollection.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCA\DAV\Files\Sharing; + +use Sabre\DAV\INode; +use Sabre\DAVACL\AbstractPrincipalCollection; +use Sabre\DAVACL\PrincipalBackend\BackendInterface; + +class RootCollection extends AbstractPrincipalCollection { + public function __construct( + private INode $root, + BackendInterface $principalBackend, + string $principalPrefix = 'principals', + ) { + parent::__construct($principalBackend, $principalPrefix); + } + + public function getChildForPrincipal(array $principalInfo): INode { + return $this->root; + } + + public function getName() { + return 'files'; + } +} |