Fix error migrating Extra with empty author in citeproc-js cheater syntax

E.g., `{:author: }`

https://forums.zotero.org/discussion/83070/error-report-id-n-a-there-was-an-error-starting-zotero
This commit is contained in:
Dan Stillman 2020-05-12 01:00:21 -04:00
parent ee474e33cb
commit 0199428c57
2 changed files with 11 additions and 0 deletions

View file

@ -995,6 +995,10 @@ Zotero.Utilities.Internal = {
let [_, originalField, value] = parts;
let key = this._normalizeExtraKey(originalField);
value = value.trim();
// Skip empty values
if (value === "") {
return [null, null];
}
return [key, value];
};

View file

@ -266,6 +266,13 @@ describe("Zotero.Utilities.Internal", function () {
assert.strictEqual(extra, '');
});
it("should ignore empty creator in citeproc-js cheater syntax", function () {
var str = '{:author: }\n';
var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str);
assert.equal(fields.size, 0);
assert.strictEqual(extra, str);
});
it("should ignore both Event Place and Publisher Place (temporary)", function () {
var str = "Event Place: Foo\nPublisher Place: Bar";
var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str);