Skip to content

Commit

Permalink
plugi
Browse files Browse the repository at this point in the history
  • Loading branch information
susnux committed Aug 26, 2024
1 parent f42038e commit 6224e0c
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 123 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function __construct(
private IRequest $request,
private IPreview $previewManager,
private IUserSession $userSession,
private IFilenameValidator $validator,
private bool $isPublic = false,
private bool $downloadAttachment = true,
) {
Expand Down Expand Up @@ -163,8 +164,7 @@ public function checkCopy($source, $destination) {
// Ensure the target name is valid
try {
[, $targetName] = \Sabre\Uri\split($destination);
$validator = \OCP\Server::get(IFilenameValidator::class);
$validator->validateFilename($targetName);
$this->validator->validateFilename($targetName);
} catch (InvalidPathException $e) {
throw new InvalidPath($e->getMessage(), false);
}
Expand Down
2 changes: 2 additions & 0 deletions apps/dav/lib/Connector/Sabre/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\DAV\Files\BrowserErrorPagePlugin;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\IFilenameValidator;
use OCP\Files\Mount\IMountManager;
use OCP\IConfig;
use OCP\IDBConnection;
Expand Down Expand Up @@ -129,6 +130,7 @@ public function createServer(string $baseUri,
$this->request,
$this->previewManager,
$this->userSession,
\OCP\Server::get(IFilenameValidator::class),
false,
!$this->config->getSystemValue('debug', false)
)
Expand Down
14 changes: 10 additions & 4 deletions apps/dav/lib/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@
use OCP\AppFramework\Http\Response;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IFilenameValidator;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IPreview;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Profiler\IProfiler;
use OCP\SabrePluginEvent;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -236,15 +240,17 @@ public function __construct(IRequest $request, string $baseUri) {
$user = $userSession->getUser();
if ($user !== null) {
$view = \OC\Files\Filesystem::getView();
$config = \OCP\Server::get(IConfig::class);
$this->server->addPlugin(
new FilesPlugin(
$this->server->tree,
\OC::$server->getConfig(),
$config,
$this->request,
\OC::$server->getPreviewManager(),
\OC::$server->getUserSession(),
\OCP\Server::get(IPreview::class),
\OCP\Server::get(IUserSession::class),
\OCP\Server::get(IFilenameValidator::class),
false,
!\OC::$server->getConfig()->getSystemValue('debug', false)
$config->getSystemValueBool('debug', false) === false,
)
);
$this->server->addPlugin(new ChecksumUpdatePlugin());
Expand Down
Loading

0 comments on commit 6224e0c

Please sign in to comment.