commit 690ceac4b3546f51f640f2adb4c8d2426e441803 parent edd4fabf2e48a294db9973b564b3008ade962979 Author: Simon Kornblith <simon@simonster.com> Date: Wed, 2 Nov 2011 00:25:47 -0400 Fix transferring documents between translator sandboxes Diffstat:
| M | chrome/content/zotero/xpcom/translation/translate.js | | | 22 | +++++++++++++++++++++- |
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -227,8 +227,28 @@ Zotero.Translate.Sandbox = { if(Zotero.isFx && !Zotero.isBookmarklet && (translate instanceof Zotero.Translate.Web || translate instanceof Zotero.Translate.Search)) { - // necessary to get around object wrappers in Firefox + // Necessary to get around object wrappers in Firefox + var attachments = item.attachments; + delete item.attachments; + item = translate._sandboxManager.sandbox.Zotero._transferItem(JSON.stringify(item)); + item.attachments = []; + + // Manually copy attachments in case there are documents, which + // can't be serialized and don't need to be + if(attachments) { + for(var i=0; i<attachments.length; i++) { + var attachment = attachments[i]; + var doc = (attachments.document ? attachments.document : undefined); + delete attachments.document; + + attachment = translate._sandboxManager.sandbox.Zotero._transferItem(JSON.stringify(item)); + + if(doc) attachment.document = doc; + + item.attachments.push(attachment); + } + } } else { // otherwise, just use parent translator's complete function item.complete = translate._sandboxManager.sandbox.Zotero.Item.prototype.complete;