aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Activity
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-02-12 16:05:42 +0100
committerJoas Schilling <coding@schilljs.com>2018-02-28 15:06:06 +0100
commitd202bae3b592f7d525d28e0b7753d8f642c20431 (patch)
tree2e8d17b1f558cab45a2d7a098a9755272ebbfea3 /apps/files/lib/Activity
parentf8c27cb57dd3dbac252cb8d41d0393d2b0d3cbd6 (diff)
downloadnextcloud-server-d202bae3b592f7d525d28e0b7753d8f642c20431.tar.gz
nextcloud-server-d202bae3b592f7d525d28e0b7753d8f642c20431.zip
Fix path handling for activities
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files/lib/Activity')
-rw-r--r--apps/files/lib/Activity/Provider.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php
index eab7e4e44ec..83f5dbaf787 100644
--- a/apps/files/lib/Activity/Provider.php
+++ b/apps/files/lib/Activity/Provider.php
@@ -29,6 +29,7 @@ use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\Files\Folder;
+use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
@@ -342,13 +343,25 @@ class Provider implements IProvider {
$encryptionContainer = $this->getEndToEndEncryptionContainer($id, basename($path));
if ($encryptionContainer instanceof Folder) {
$this->fileIsEncrypted = true;
- return [
- 'type' => 'file',
- 'id' => $encryptionContainer->getId(),
- 'name' => $encryptionContainer->getName(),
- 'path' => trim($encryptionContainer->getPath(), '/'), // FIXME remove /user/files/...
- 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $encryptionContainer->getId()]),
- ];
+ try {
+ $fullPath = rtrim($encryptionContainer->getPath(), '/');
+ // Remove /user/files/...
+ list(,,, $path) = explode('/', $fullPath, 4);
+ if (!$path) {
+ throw new InvalidPathException('Path could not be split correctly');
+ }
+
+ return [
+ 'type' => 'file',
+ 'id' => $encryptionContainer->getId(),
+ 'name' => $encryptionContainer->getName(),
+ 'path' => $path,
+ 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $encryptionContainer->getId()]),
+ ];
+ } catch (\Exception $e) {
+ // fall back to the normal one
+ $this->fileIsEncrypted = false;
+ }
}
return [