mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(files_sharing): Switch back event path to be relative to user folder
This is clearly the original intent, the parameter name in ViewOnly is $userFolder, and the similar event for single file download uses paths relative to user folder as well. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
102c5183e1
commit
7a88cb0709
3 changed files with 9 additions and 4 deletions
|
|
@ -48,7 +48,7 @@ class BeforeZipCreatedListener implements IEventListener {
|
|||
$user = $this->userSession->getUser();
|
||||
if ($user) {
|
||||
$viewOnlyHandler = new ViewOnly(
|
||||
$this->rootFolder
|
||||
$this->rootFolder->getUserFolder($user->getUID())
|
||||
);
|
||||
if (!$viewOnlyHandler->check($pathsToCheck)) {
|
||||
$event->setErrorMessage('Access to this resource or one of its sub-items has been denied.');
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ViewOnly {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $pathsToCheck
|
||||
* @param string[] $pathsToCheck paths to check, relative to the user folder
|
||||
* @return bool
|
||||
*/
|
||||
public function check(array $pathsToCheck): bool {
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@ use OCP\Files\Folder;
|
|||
* @since 25.0.0
|
||||
*/
|
||||
class BeforeZipCreatedEvent extends Event {
|
||||
private string $directory;
|
||||
private ?string $directory = null;
|
||||
private bool $successful = true;
|
||||
private ?string $errorMessage = null;
|
||||
private ?Folder $folder = null;
|
||||
|
||||
/**
|
||||
* @param string|Folder $directory Folder instance, or (deprecated) string path relative to user folder
|
||||
* @param list<string> $files
|
||||
* @since 25.0.0
|
||||
* @since 31.0.0 support `OCP\Files\Folder` as `$directory` parameter - passing a string is deprecated now
|
||||
|
|
@ -37,7 +38,6 @@ class BeforeZipCreatedEvent extends Event {
|
|||
) {
|
||||
parent::__construct();
|
||||
if ($directory instanceof Folder) {
|
||||
$this->directory = $directory->getPath();
|
||||
$this->folder = $directory;
|
||||
} else {
|
||||
$this->directory = $directory;
|
||||
|
|
@ -53,8 +53,13 @@ class BeforeZipCreatedEvent extends Event {
|
|||
|
||||
/**
|
||||
* @since 25.0.0
|
||||
* @deprecated 33.0.0 Use getFolder instead and use node API
|
||||
* @return string returns folder path relative to user folder
|
||||
*/
|
||||
public function getDirectory(): string {
|
||||
if ($this->folder instanceof Folder) {
|
||||
return preg_replace('|^/[^/]+/files/|', '/', $this->folder->getPath());
|
||||
}
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue