From: Ferdinand Thiessen Date: Thu, 23 Nov 2023 20:34:36 +0000 (+0100) Subject: fix(files): Correct condition for checking copy/move into same directory X-Git-Tag: v29.0.0beta1~778^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2357f839fefa4cb0629e7fe29d3f2c1ab9d92fd3;p=nextcloud-server.git fix(files): Correct condition for checking copy/move into same directory Signed-off-by: Ferdinand Thiessen --- diff --git a/apps/files/src/actions/moveOrCopyAction.ts b/apps/files/src/actions/moveOrCopyAction.ts index 17e9370e8d9..22afb79c4d6 100644 --- a/apps/files/src/actions/moveOrCopyAction.ts +++ b/apps/files/src/actions/moveOrCopyAction.ts @@ -80,7 +80,13 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth throw new Error(t('files', 'This file/folder is already in that directory')) } - if (node.path.startsWith(destination.path)) { + /** + * Example: + * node: /foo/bar/file.txt -> path = /foo/bar + * destination: /foo + * Allow move of /foo does not start with /foo/bar so allow + */ + if (destination.path.startsWith(node.path)) { throw new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself')) }