From 86689ef40033f117154f9f6e65359cdad39530e9 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 26 Jan 2015 17:06:07 +0100 Subject: [PATCH 1/2] Disable JS plugin for sharing in public mode This removes the logic that registers the share action and modifies the rows. Share actions aren't needed in the public file list. --- apps/files_sharing/js/share.js | 2 +- apps/files_sharing/tests/js/shareSpec.js | 26 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 3a16c1f2edd..11c3170c2f0 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -25,7 +25,7 @@ * @param {OCA.Files.FileList} fileList file list to be extended */ attach: function(fileList) { - if (fileList.id === 'trashbin') { + if (fileList.id === 'trashbin' || fileList.id === 'files.public') { return; } var fileActions = fileList.fileActions; diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js index e5b5de314d7..1b1e363b792 100644 --- a/apps/files_sharing/tests/js/shareSpec.js +++ b/apps/files_sharing/tests/js/shareSpec.js @@ -27,7 +27,7 @@ describe('OCA.Sharing.Util tests', function() { $('#testArea').append($content); // dummy file list var $div = $( - '
' + + '
' + '' + '' + '' + @@ -450,5 +450,29 @@ describe('OCA.Sharing.Util tests', function() { .toEqual('User four, User one, User three, User two, +6'); }); }); + describe('Excluded lists', function() { + function createListThenAttach(listId) { + var fileActions = new OCA.Files.FileActions(); + fileList.destroy(); + fileList = new OCA.Files.FileList( + $('#listContainer'), { + id: listId, + fileActions: fileActions + } + ); + OCA.Sharing.Util.attach(fileList); + fileList.setFiles(testFiles); + return fileList; + } + + it('does not attach to trashbin or public file lists', function() { + createListThenAttach('trashbin'); + expect($('.action-share').length).toEqual(0); + expect($('[data-share-recipient]').length).toEqual(0); + createListThenAttach('files.public'); + expect($('.action-share').length).toEqual(0); + expect($('[data-share-recipient]').length).toEqual(0); + }); + }); }); From efcd89cb18ea9e553d1d7a52f35cd61b499cf184 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 26 Jan 2015 17:10:58 +0100 Subject: [PATCH 2/2] Do not disclose share owner in public file list --- apps/files_sharing/ajax/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/ajax/list.php b/apps/files_sharing/ajax/list.php index 073c86365be..657c6f75da5 100644 --- a/apps/files_sharing/ajax/list.php +++ b/apps/files_sharing/ajax/list.php @@ -64,7 +64,10 @@ $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection); $formattedFiles = array(); foreach ($files as $file) { $entry = \OCA\Files\Helper::formatFileInfo($file); - unset($entry['directory']); // for now + // for now + unset($entry['directory']); + // do not disclose share owner + unset($entry['shareOwner']); $entry['permissions'] = \OCP\Constants::PERMISSION_READ; $formattedFiles[] = $entry; }