fix(files): check that node is in user root folder for view-in-folder action

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
skjnldsv 2024-11-08 09:23:12 +01:00 committed by nextcloud-command
parent 38694e9acc
commit 490716176e
2 changed files with 17 additions and 0 deletions

View file

@ -109,6 +109,18 @@ describe('View in folder action enabled tests', () => {
expect(action.enabled).toBeDefined()
expect(action.enabled!([folder], view)).toBe(false)
})
test('Disabled for files outside the user root folder', () => {
const file = new Folder({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/trashbin/admin/trash/image.jpg.d1731053878',
owner: 'admin',
permissions: Permission.READ,
})
expect(action.enabled).toBeDefined()
expect(action.enabled!([file], view)).toBe(false)
})
})
describe('View in folder action execute tests', () => {

View file

@ -30,6 +30,11 @@ export const action = new FileAction({
return false
}
// Can only view files that are in the user root folder
if (!node.root?.startsWith('/files')) {
return false
}
if (node.permissions === Permission.NONE) {
return false
}