mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
Avoid handling clipboard data item if it is not file type
This commit is contained in:
parent
bb9a5772bc
commit
7eb96eb3cb
|
@ -3110,19 +3110,15 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
function addClipboardEventHandler() {
|
function addClipboardEventHandler() {
|
||||||
$(document).on('paste', function (event) {
|
$(document).on('paste', function (event) {
|
||||||
|
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||||
|
const lastItem = items[items.length - 1];
|
||||||
|
if (lastItem.kind === 'file') {
|
||||||
if (TopNav.isAttachmentReadonly()) {
|
if (TopNav.isAttachmentReadonly()) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
readFileData(lastItem.getAsFile());
|
||||||
for (let i = 0; i < items.length; ++i) {
|
|
||||||
if (items[i].kind === 'file') {
|
|
||||||
//Clear the file input:
|
|
||||||
$fileInput.wrap('<form>').closest('form').get(0).reset();
|
|
||||||
$fileInput.unwrap();
|
|
||||||
|
|
||||||
readFileData(items[i].getAsFile());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user