From abe8c39c5b644407b0d8dd88a16844c1fae36f8d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 19 Dec 2021 03:01:17 -0500 Subject: [PATCH] Ignore blank tags when saving from translator Instead of throwing an error --- chrome/content/zotero/xpcom/translation/translate_item.js | 3 +++ test/tests/translateTest.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index fd8e6a7c9c..14462e4e23 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -979,6 +979,9 @@ Zotero.Translate.ItemSaver.prototype = { if (typeof tag == 'string') { tag = { tag }; } + if (!tag.tag.trim()) { + continue; + } tag.type = this._forceTagType || tag.type || 0; newTags.push(tag); } diff --git a/test/tests/translateTest.js b/test/tests/translateTest.js index ea83ab985a..3078cd66b9 100644 --- a/test/tests/translateTest.js +++ b/test/tests/translateTest.js @@ -59,7 +59,9 @@ const TEST_TAGS = [ {"tag":"manual tag as object"}, {"tag":"manual tag as object with type", "type":0}, {"tag":"automatic tag as object", "type":1}, - {"name":"tag in name property"} + {"name":"tag in name property"}, + { name: "" }, + { name: " " }, ]; /**