Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Constants;
use OCP\DirectEditing\IManager as IDirectEditingManager;
use OCP\DirectEditing\RegisterDirectEditorEvent;
use OCP\EventDispatcher\IEventDispatcher;
Expand All @@ -61,6 +62,7 @@
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
Expand Down Expand Up @@ -92,7 +94,10 @@ class WorkspaceController extends OCSController {
/** @var LoggerInterface */
private $logger;

public function __construct($appName, IRequest $request, IRootFolder $rootFolder, IManager $shareManager, IDirectEditingManager $directEditingManager, IURLGenerator $urlGenerator, WorkspaceService $workspaceService, IEventDispatcher $eventDispatcher, LoggerInterface $logger, $userId) {
/** @var ISession */
private $session;

public function __construct($appName, IRequest $request, IRootFolder $rootFolder, IManager $shareManager, IDirectEditingManager $directEditingManager, IURLGenerator $urlGenerator, WorkspaceService $workspaceService, IEventDispatcher $eventDispatcher, LoggerInterface $logger, ISession $session, $userId) {
parent::__construct($appName, $request);
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
Expand All @@ -102,6 +107,7 @@ public function __construct($appName, IRequest $request, IRootFolder $rootFolder
$this->urlGenerator = $urlGenerator;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
$this->session = $session;
}

/**
Expand Down Expand Up @@ -155,6 +161,15 @@ public function folder(string $path = '/'): DataResponse {
public function publicFolder(string $shareToken, string $path = '/'): DataResponse {
try {
$share = $this->shareManager->getShareByToken($shareToken);
if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
throw new ShareNotFound();
}
if ($share->getPassword() !== null) {
$shareId = $this->session->get('public_link_authenticated');
if ($share->getId() !== $shareId) {
throw new ShareNotFound();
}
}
$folder = $share->getNode()->get($path);
if ($folder instanceof Folder) {
$file = $this->workspaceService->getFile($folder);
Expand Down
20 changes: 4 additions & 16 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<code>LoadViewer</code>
</UndefinedClass>
</file>
<file src="lib/Command/ResetDocument.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>void</code>
</ImplementedReturnTypeMismatch>
</file>
<file src="lib/Controller/DirectSessionController.php">
<UndefinedClass occurrences="1">
<code>InvalidTokenException</code>
Expand All @@ -32,32 +27,25 @@
</UndefinedThisPropertyFetch>
</file>
<file src="lib/Controller/WorkspaceController.php">
<InvalidCatch occurrences="2"/>
<InvalidCatch occurrences="1"/>
<InvalidReturnType occurrences="3">
<code>DataResponse</code>
<code>DataResponse</code>
<code>DataResponse</code>
</InvalidReturnType>
<MissingDependency occurrences="9">
<code>$e</code>
<code>$e</code>
<MissingDependency occurrences="8">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
<code>ShareNotFound</code>
<code>StorageNotAvailableException</code>
<code>ShareNotFound</code>
<code>ShareNotFound</code>
<code>StorageNotAvailableException</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>Exception</code>
</UndefinedClass>
<UndefinedInterfaceMethod occurrences="1">
<code>open</code>
</UndefinedInterfaceMethod>
<UndefinedThisPropertyFetch occurrences="1">
<code>$this-&gt;logger</code>
</UndefinedThisPropertyFetch>
</file>
<file src="lib/DAV/WorkspacePlugin.php">
<UndefinedClass occurrences="1">
Expand Down