From 5236d01791f36f2758675d437ebe22ad168d7f4a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 21 Jan 2017 06:33:36 -0500 Subject: [PATCH] Fix mangled large reports https://forums.zotero.org/discussion/64022/5-0-beta-generate-report-is-often-garbled Records are being truncated, though I'm not sure why. But just read the input stream into a string for now. --- components/zotero-protocol-handler.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/zotero-protocol-handler.js b/components/zotero-protocol-handler.js index 14e30a946c..1a2ac6a671 100644 --- a/components/zotero-protocol-handler.js +++ b/components/zotero-protocol-handler.js @@ -444,12 +444,26 @@ function ZoteroProtocolHandler() { default: this.contentType = 'text/html'; - return Zotero.Utilities.Internal.getAsyncInputStream( + + // DEBUG: Results in mangled reports + // + // https://forums.zotero.org/discussion/64022/5-0-beta-generate-report-is-often-garbled + /*return Zotero.Utilities.Internal.getAsyncInputStream( + Zotero.Report.HTML.listGenerator(items, combineChildItems), + function () { + return 'Error generating report'; + } + );*/ + + Components.utils.import("resource://gre/modules/NetUtil.jsm"); + var is = Zotero.Utilities.Internal.getAsyncInputStream( Zotero.Report.HTML.listGenerator(items, combineChildItems), function () { return 'Error generating report'; } ); + var str = NetUtil.readInputStreamToString(is, is.available(), {}); + return Zotero.Promise.resolve(str); } }); }