From f8ae1bb36e59d1110db24a3fdc5079daa97f3753 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 22 Mar 2016 20:28:57 +0100 Subject: [PATCH] Disable pastezone for jquery.fileupload jquery.fileupload offers the [`pastezone`](https://github.com/blueimp/jQuery-File-Upload/wiki/Options#pastezone) functionality. This functionality is enabled by default and if somebody copy-pastes something into Chrome it will automatically trigger an upload of the content to any configured jquery.fileupload element embedded in the JS. This implementation triggers some problems: 1. The pastezone is defined globally by default (:see_no_evil:). So if there are multiple fileupload's on a page (such as in the personal settings) then stuff is going to be uploaded to all embedded uploads. 2. Our server code is not able to parse the data. For example for uploads in the files app we expect a file name which is not specified => Just an error is thrown. You can reproduce this by taking a file into your clipboard and in Chrome then pressing CTRL + V. 3. When copy-pasting some string from MS Office on the personal page a temporary avatar with said content is created. Considering that this is anyways was never working at all and causes bugs I've set the `pastezone` to `null`. This mens that upload via copy and paste will be disabled. Lesson learned: Third-party JS libraries can have some weird details. --- apps/files/js/file-upload.js | 1 + settings/js/certificates.js | 1 + settings/js/personal.js | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index bd80afd072..fca69064cd 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -274,6 +274,7 @@ OC.Upload = { if ( $('#file_upload_start').exists() ) { var file_upload_param = { dropZone: $('#content'), // restrict dropZone to content div + pasteZone: null, autoUpload: false, sequentialUploads: true, //singleFileUploads is on by default, so the data.files array will always have length 1 diff --git a/settings/js/certificates.js b/settings/js/certificates.js index 9ce9f9aa8d..f2a8e6b0af 100644 --- a/settings/js/certificates.js +++ b/settings/js/certificates.js @@ -16,6 +16,7 @@ $(document).ready(function () { $('#sslCertificate tr > td').tipsy({gravity: 'n', live: true}); $('#rootcert_import').fileupload({ + pasteZone: null, submit: function (e, data) { data.formData = _.extend(data.formData || {}, { requesttoken: OC.requestToken diff --git a/settings/js/personal.js b/settings/js/personal.js index 3b2316d061..bd13b7fd25 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -244,6 +244,7 @@ $(document).ready(function () { }); var uploadparms = { + pasteZone: null, done: function (e, data) { var response = data; if (typeof data.result === 'string') {