summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-04-02 16:59:51 +0200
committerGitHub <noreply@github.com>2021-04-02 16:59:51 +0200
commitb59cf16325d6d4f28913038ac9db99e357c3763a (patch)
treedbf35eb2c09d422579efb8d5cd5bc2623f517f9f /lib/private
parente14860c8f201bea5207d7959ec71ccb45eb010c9 (diff)
parentdc8e819915acc045bcbc67df098231db30ffb240 (diff)
downloadnextcloud-server-b59cf16325d6d4f28913038ac9db99e357c3763a.tar.gz
nextcloud-server-b59cf16325d6d4f28913038ac9db99e357c3763a.zip
Merge pull request #26406 from nextcloud/backport/26396/stable21
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DirectEditing/Manager.php8
-rw-r--r--lib/private/Files/Template/TemplateManager.php12
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php
index 0e7e988eef2..1ea09e74d59 100644
--- a/lib/private/DirectEditing/Manager.php
+++ b/lib/private/DirectEditing/Manager.php
@@ -27,6 +27,7 @@
namespace OC\DirectEditing;
use Doctrine\DBAL\FetchMode;
+use OC\Files\Node\Folder;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
@@ -130,7 +131,12 @@ class Manager implements IManager {
if ($userFolder->nodeExists($path)) {
throw new \RuntimeException('File already exists');
} else {
- $file = $userFolder->newFile($path);
+ if (!$userFolder->nodeExists(dirname($path))) {
+ throw new \RuntimeException('Invalid path');
+ }
+ /** @var Folder $folder */
+ $folder = $userFolder->get(dirname($path));
+ $file = $folder->newFile(basename($path));
$editor = $this->getEditor($editorId);
$creators = $editor->getCreators();
foreach ($creators as $creator) {
diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php
index 44e1b10fa35..3dd7f82bff3 100644
--- a/lib/private/Files/Template/TemplateManager.php
+++ b/lib/private/Files/Template/TemplateManager.php
@@ -36,7 +36,6 @@ use OCP\Files\GenericFileException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
-use OCP\Files\NotPermittedException;
use OCP\Files\Template\FileCreatedFromTemplateEvent;
use OCP\Files\Template\ICustomTemplateProvider;
use OCP\Files\Template\ITemplateManager;
@@ -154,7 +153,11 @@ class TemplateManager implements ITemplateManager {
} catch (NotFoundException $e) {
}
try {
- $targetFile = $userFolder->newFile($filePath);
+ if (!$userFolder->nodeExists(dirname($filePath))) {
+ throw new GenericFileException($this->l10n->t('Invalid path'));
+ }
+ $folder = $userFolder->get(dirname($filePath));
+ $targetFile = $folder->newFile(basename($filePath));
if ($templateType === 'user' && $templateId !== '') {
$template = $userFolder->get($templateId);
$template->copy($targetFile->getPath());
@@ -295,9 +298,10 @@ class TemplateManager implements ITemplateManager {
}
try {
- $folder = $userFolder->newFolder($userTemplatePath);
- } catch (NotPermittedException $e) {
$folder = $userFolder->get($userTemplatePath);
+ } catch (NotFoundException $e) {
+ $folder = $userFolder->get(dirname($userTemplatePath));
+ $folder = $folder->newFolder(basename($userTemplatePath));
}
$folderIsEmpty = count($folder->getDirectoryListing()) === 0;