Skip to content

Commit

Permalink
fix(files): check that node is in user root folder for view-in-folder…
Browse files Browse the repository at this point in the history
… action

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Nov 9, 2024
1 parent 832d479 commit 0f918c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/files/src/actions/viewInFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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', () => {
Expand Down
5 changes: 5 additions & 0 deletions apps/files/src/actions/viewInFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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
}
Expand Down

0 comments on commit 0f918c8

Please sign in to comment.