Skip to content

Commit

Permalink
Merge pull request #5672 from nextcloud/upload-hidden-filelist
Browse files Browse the repository at this point in the history
properly block file upload to non-active filelist
  • Loading branch information
MorrisJobke authored Jul 11, 2017
2 parents 23ff769 + e1d6ca3 commit 4153e1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,7 @@

if (self.$el.hasClass('hidden')) {
// do not upload to invisible lists
e.preventDefault();
return false;
}

Expand All @@ -2753,6 +2754,7 @@
&& !self.$el.has(dropTarget).length // dropped inside list
&& !dropTarget.is(self.$container) // dropped on main container
) {
e.preventDefault();
return false;
}

Expand Down
20 changes: 11 additions & 9 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2808,22 +2808,24 @@ describe('OCA.Files.FileList tests', function() {
var eventData = {
delegatedEvent: {
target: $target
},
preventDefault: function () {
}
};
uploader.trigger('drop', eventData, data || {});
return !!data.targetDir;
}

it('drop on a tr or crumb outside file list does not trigger upload', function() {
var $anotherTable = $('<table><tbody><tr><td>outside<div class="crumb">crumb</div></td></tr></table>');
var ev;
$('#testArea').append($anotherTable);
ev = dropOn($anotherTable.find('tr'), uploadData);
expect(ev).toEqual(false);
it('drop on a tr or crumb outside file list does not trigger upload', function() {
var $anotherTable = $('<table><tbody><tr><td>outside<div class="crumb">crumb</div></td></tr></table>');
var ev;
$('#testArea').append($anotherTable);
ev = dropOn($anotherTable.find('tr'), uploadData);
expect(ev).toEqual(false);

ev = dropOn($anotherTable.find('.crumb'), uploadData);
expect(ev).toEqual(false);
});
ev = dropOn($anotherTable.find('.crumb'), uploadData);
expect(ev).toEqual(false);
});
it('drop on an element outside file list container does not trigger upload', function() {
var $anotherEl = $('<div>outside</div>');
var ev;
Expand Down

0 comments on commit 4153e1d

Please sign in to comment.