commit a78cd2cf18ced34dbdf15a1e6eb50dbc86bb9b7e
parent 39c86a791ed319134568db97aa1fbb25f2b8caba
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 5 Feb 2012 18:58:15 -0500
Fix WPD leak by loading into a local scope
Diffstat:
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git 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
@@ -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<xpcomFilesAll.length; i++) {
try {