From a78cd2cf18ced34dbdf15a1e6eb50dbc86bb9b7e Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 5 Feb 2012 18:58:15 -0500 Subject: [PATCH] Fix WPD leak by loading into a local scope --- chrome/content/zotero/xpcom/attachments.js | 13 +++++++++++-- components/zotero-service.js | 9 --------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 125dc4dc8c..0b0796cc2a 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -567,8 +567,17 @@ Zotero.Attachments = new function(){ if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') { var sync = true; - Zotero.WebPageDump.wpdDOMSaver.init(file.path, document); - Zotero.WebPageDump.wpdDOMSaver.saveHTMLDocument(); + // Load WebPageDump code + var wpd = {"Zotero":Zotero}; + Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader) + .loadSubScript("chrome://zotero/content/webpagedump/common.js", wpd); + Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader) + .loadSubScript("chrome://zotero/content/webpagedump/domsaver.js", wpd); + + wpd.wpdDOMSaver.init(file.path, document); + wpd.wpdDOMSaver.saveHTMLDocument(); attachmentItem.attachmentPath = this.getPath( file, Zotero.Attachments.LINK_MODE_IMPORTED_URL diff --git a/components/zotero-service.js b/components/zotero-service.js index 71d2993a80..070c062738 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -206,15 +206,6 @@ function makeZoteroContext(isConnector) { .getService(Ci.mozIJSSubScriptLoader) .loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc); - // Load WPD into Zotero.WebPageDump namespace - zContext.Zotero.WebPageDump = {"Zotero":zContext.Zotero}; - Components.classes["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Components.interfaces.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/webpagedump/common.js", zContext.Zotero.WebPageDump); - Components.classes["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Components.interfaces.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/webpagedump/domsaver.js", zContext.Zotero.WebPageDump); - // Load remaining xpcomFiles for (var i=1; i