BibTeX export: bug related to "pages" field and solution

Lately my colleagues and I have repeatedly encountered the following bug.
(We have reset the translators and updated them manually from the repository.)
This has also been filed as error report # 930829584 from within zotero.
Most likely, the bug reported under http://forums.zotero.org/discussion/3329/issues-when-exporting-to-bibtex-zotero-106-on-ff3 is a duplicate of this report, or vice versa.

When exporting to BibTeX the export stops at certain items and a javascript error pops up, saying
"An error occurred while trying to export the selected file."
The resulting .bib file just ends in the middle of the pertaining items right before the "pages" field.
The error console shows:
[JavaScript Error: "item.pages.replace is not a function" {file: "chrome://zotero/content/xpcom/translate.js" line: 2465}]

The problem seems to be that there is an implicit cast to a string (or no cast at all) in the BibTeX translator. Changing the line that reads

writeField("pages", item.pages.replace("-","--"));

into

writeField("pages", item.pages.toString().replace("-","--"));

seems to fix the problem.
(Apparently jscript sometimes interprets the pages field as a number... The toString() cast is fine with the items where the field was already interpreted as string. However, I am not sure if I missed other places in the code where a similar error could occur.)

I hope the developers will read this and this post will be helpful to them. Thank you for your work on zotero!
  • edited December 9, 2008
    This is already fixed in the latest dev builds of Zotero. (The problem is in the data layer, not the translator, though your workaround will work.) The fix will be included in 1.0.8. Thanks.
Sign In or Register to comment.