aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-05-15 11:26:33 +0200
committerGitHub <noreply@github.com>2023-05-15 11:26:33 +0200
commitdee180409b9b245ce9bdc78e1aacdfb85ae7055d (patch)
tree7bbd79bd709a62168ee6aba46c79bb4b5e4c3cc3
parent4e05c6fa795b6b4d51194f383134522c47e2803d (diff)
parent8faf854a036642365e8f60a3269913dbec763199 (diff)
downloadnextcloud-server-dee180409b9b245ce9bdc78e1aacdfb85ae7055d.tar.gz
nextcloud-server-dee180409b9b245ce9bdc78e1aacdfb85ae7055d.zip
Merge pull request #38203 from nextcloud/backport/36893/stable25
[stable25] Make sure to never trigger files hooks on a null path
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php18
-rw-r--r--lib/private/Files/Node/HookConnector.php5
2 files changed, 14 insertions, 9 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 94632b265db..4f1cde334d9 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -422,14 +422,15 @@ class File extends Node implements IFile {
}
}
- /**
- * @param string $path
- */
- private function emitPreHooks($exists, $path = null) {
+ private function emitPreHooks(bool $exists, ?string $path = null): bool {
if (is_null($path)) {
$path = $this->path;
}
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
+ if ($hookPath === null) {
+ // We only trigger hooks from inside default view
+ return true;
+ }
$run = true;
if (!$exists) {
@@ -450,14 +451,15 @@ class File extends Node implements IFile {
return $run;
}
- /**
- * @param string $path
- */
- private function emitPostHooks($exists, $path = null) {
+ private function emitPostHooks(bool $exists, ?string $path = null): void {
if (is_null($path)) {
$path = $this->path;
}
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
+ if ($hookPath === null) {
+ // We only trigger hooks from inside default view
+ return;
+ }
if (!$exists) {
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, [
\OC\Files\Filesystem::signal_param_path => $hookPath
diff --git a/lib/private/Files/Node/HookConnector.php b/lib/private/Files/Node/HookConnector.php
index 149ffafd46b..c61e098c227 100644
--- a/lib/private/Files/Node/HookConnector.php
+++ b/lib/private/Files/Node/HookConnector.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -223,7 +226,7 @@ class HookConnector {
$this->dispatcher->dispatchTyped($event);
}
- private function getNodeForPath($path) {
+ private function getNodeForPath(string $path): Node {
$info = Filesystem::getView()->getFileInfo($path);
if (!$info) {
$fullPath = Filesystem::getView()->getAbsolutePath($path);