From 8f7a160ba14d260f2e2f36d2cef2ab155d56adc1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 19 Jun 2022 15:20:54 -0400 Subject: [PATCH] =?UTF-8?q?fx-compat:=20`getURLSpecFromFile()`=20=E2=86=92?= =?UTF-8?q?=20`Zotero.File.pathToFileURI()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One remaining instance in the prefs that will need to be fixed --- chrome/content/zotero/itemTree.jsx | 4 +--- chrome/content/zotero/xpcom/data/item.js | 8 ++------ .../content/zotero/xpcom/translation/translate_firefox.js | 8 +------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 4220466cbc..c06656726a 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -1952,9 +1952,7 @@ var ItemTree = class ItemTree extends LibraryTree { let uri; if (!Zotero.isMac) { Zotero.debug("Adding text/x-moz-url " + i); - let fph = Cc["@mozilla.org/network/protocol;1?name=file"] - .createInstance(Ci.nsIFileProtocolHandler); - uri = fph.getURLSpecFromFile(file); + uri = Zotero.File.pathToFileURI(file); event.dataTransfer.mozSetDataAt("text/x-moz-url", uri + '\n' + file.leafName, i); } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 4e7b80c8d7..832f571ecf 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2941,15 +2941,11 @@ Zotero.Item.prototype.getLocalFileURL = function() { if (!this.isAttachment()) { throw ("getLocalFileURL() can only be called on attachment items"); } - - var file = this.getFile(); + var file = this.getFilePath(); if (!file) { return false; } - - var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"] - .getService(Components.interfaces.nsIFileProtocolHandler); - return nsIFPH.getURLSpecFromFile(file); + return Zotero.File.pathToFileURI(file); } diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 9910ddc174..2982c5630a 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -676,18 +676,12 @@ Zotero.Translate.IO.Read.prototype = { }, "_initRDF":function() { - // get URI - var IOService = Components.classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService); - var fileHandler = IOService.getProtocolHandler("file") - .QueryInterface(Components.interfaces.nsIFileProtocolHandler); - var baseURI = fileHandler.getURLSpecFromFile(this.file); - Zotero.debug("Translate: Initializing RDF data store"); this._dataStore = new Zotero.RDF.AJAW.IndexedFormula(); var parser = new Zotero.RDF.AJAW.RDFParser(this._dataStore); try { var nodes = Zotero.Translate.IO.parseDOMXML(this._rawStream, this._charset, this.file.fileSize); + let baseURI = Zotero.File.pathToFileURI(this.file); parser.parse(nodes, baseURI); this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore);