1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

fix to prevent uploging unexpected file type

This commit is contained in:
Hiroyasu Nishiyama 2023-01-25 13:38:12 +09:00
parent b9fe4c5cd3
commit f1801f9662
2 changed files with 16893 additions and 7 deletions

16880
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -51,15 +51,21 @@
var files = ev.originalEvent.dataTransfer.files; var files = ev.originalEvent.dataTransfer.files;
if (files.length === 1) { if (files.length === 1) {
var file = files[0]; var file = files[0];
var image = file2base64Image(file, function (image) { var name = file.name.toLowerCase();
var session = currentEditor.getSession();
var img = `<img src="${image}"/>\n`; if (name.match(/\.(apng|avif|gif|jpeg|png|svg|webp)$/)) {
var pos = session.getCursorPosition(); var image = file2base64Image(file, function (image) {
session.insert(pos, img); var session = currentEditor.getSession();
$("#red-ui-image-drop-target").hide(); var img = `<img src="${image}"/>\n`;
}); var pos = session.getCursorPosition();
session.insert(pos, img);
$("#red-ui-image-drop-target").hide();
});
return;
}
} }
} }
$("#red-ui-image-drop-target").hide();
}); });
} }
} }