How to restrict drag and drop .exe file

Hi, I don't want to allow .exe file to drag and drop by user while edit document. Can any one tell me how to do this.

1 votes

1 answers

2125 views

ANSWER



Hi, I have fixed this bug by changing code in jquery.dnd-file-upload.js of nuxeo-platform-webapp-base bundle. In this file I have change function processFileOrFolderEntryAsync() as fillows:


function processFileOrFolderEntryAsync(fileOb, opts, fileCB, folderCB, transferItem) {

// filter Folders from dropped content
// Folder size is 0 under Win / %4096 under Linux / variable under MacOS
if(fileOb.type =="application/x-ms-dos-executable"){// code added for not to allow .exe files to drag and drop
alert(".exe file not allowed");
cancelUploadIfNoValidFileWasDropped(opts) // code added for not to allow .exe files to drag and drop
 }else if (!fileOb.type && fileOb.size < (4096 * 4 + 1)) {
  try {
    // need to test the file by reading it ...
        var reader = new FileReader();
        reader.onerror = function (e) {
          folderCB(fileOb, opts, transferItem);
        };
        reader.onabort = function (e) {
          folderCB(fileOb, opts, transferItem);
        };
        reader.onload = function (e) {
          fileCB(fileOb, opts);
        };
        reader.readAsText(fileOb);
  } catch (err) {
    folderCB(fileOb, opts, transferItem);
  }
} else {
  fileCB(fileOb, opts);
}

}

0 votes



hi santhosh,

I am also facing the same issue. can you please tell me from where I can get this file jquery.dnd-file-upload.js to edit?

06/10/2021