Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression in 1.2.33: state.tmp.name_node.children is undefined

dstillman opened this issue · comments

We got a report from a Zotero user using the Journal of Marketing style, which is American Marketing Association.

Zotero is currently on citeproc-js 1.3.22, but I traced this regression to 1.2.33, presumably this commit. It still happens on 1.4.6.

Here's the error:

zotero(3)(+0000107): TypeError: state.tmp.name_node.children is undefined
    func@chrome://zotero/content/xpcom/citeproc.js:19116:37
    CSL.tokenExec@chrome://zotero/content/xpcom/citeproc.js:2752:21
    CSL.expandMacro/func</<@chrome://zotero/content/xpcom/citeproc.js:2827:28
    CSL.tokenExec@chrome://zotero/content/xpcom/citeproc.js:2752:21
    CSL.expandMacro/func</<@chrome://zotero/content/xpcom/citeproc.js:2827:28
    CSL.tokenExec@chrome://zotero/content/xpcom/citeproc.js:2752:21
    CSL.getCite@chrome://zotero/content/xpcom/citeproc.js:8193:16
    CSL.getBibliographyEntries@chrome://zotero/content/xpcom/citeproc.js:8633:38
    CSL.Engine.prototype.makeBibliography@chrome://zotero/content/xpcom/citeproc.js:8401:11
    getCiteprocBibliography@chrome://zotero/content/xpcom/integration.js:2958:24
    Zotero.Integration.Fields.prototype._updateDocument@chrome://zotero/content/xpcom/integration.js:1179:17

In our build, that's this line:

citeproc-js/citeproc.js

Lines 19113 to 19116 in 1f87b7b

// This is a wee bit risky, as we're assuming that the name
// children and the list of stringified names are congruent.
// That *should* always be true, but you never know.
for (i = 0, ilen = state.tmp.name_node.children.length; i < ilen; i += 1) {

I reproduced this generating a bibliography in a large user document. If the problem here isn't obvious, I can try to narrow it down further.

I was able to build a failing test in the first go. It's not related to the congruency issue flagged in the comment, it's a bit simpler. The bug is triggered with partial-each substitution whenever names fail and an ordinary field is rendered via cs:substitute. Working on a fix for it now.

This is now fixed in tag 1.4.7. The release also contains a fix for locale-specific title-casing raised earlier on the forums.

Thanks! Now available in the Zotero beta.