From 3c6ae0e6560e2ecb3c611c573d55aa22c763aeea Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 8 Sep 2020 04:08:44 -0400 Subject: [PATCH] Throw on missing parentItemID in Attachments.importEmbeddedImage() --- chrome/content/zotero/xpcom/attachments.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index fa25564d77..470e6a8a12 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -358,13 +358,17 @@ Zotero.Attachments = new function(){ * * @param {Object} params * @param {Blob} params.blob - Image to save - * @param {Integer} params.parentItemID - Annotation item to add item to + * @param {Integer} params.parentItemID - Note or annotation item to add item to * @param {Object} [params.saveOptions] - Options to pass to Zotero.Item::save() * @return {Promise} */ this.importEmbeddedImage = async function ({ blob, parentItemID, saveOptions }) { Zotero.debug('Importing note or annotation image'); + if (!parentItemID) { + throw new Error("parentItemID must be provided"); + } + var contentType = blob.type; var fileExt; switch (contentType) { @@ -379,7 +383,7 @@ Zotero.Attachments = new function(){ break; default: - throw new Error(`Unsupported embedded image content type '${contentType}`); + throw new Error(`Unsupported embedded image content type '${contentType}'`); } var filename = 'image.' + fileExt;