diff --git a/toolkit/modules/GMPExtractorWorker.js b/toolkit/modules/GMPExtractorWorker.js index d4835da90d22..6f1ff8f9c052 100644 --- a/toolkit/modules/GMPExtractorWorker.js +++ b/toolkit/modules/GMPExtractorWorker.js @@ -13,7 +13,9 @@ const FILE_ENTRY = "201: "; onmessage = async function(msg) { try { let extractedPaths = []; - let jarPath = "jar:file://" + msg.data.zipPath + "!/"; + // Construct a jar URI from the file URI so we can use the JAR URI scheme + // handling to navigate inside the zip file. + let jarPath = "jar:" + msg.data.zipURI + "!/"; let jarResponse = await fetch(jarPath); let dirListing = await jarResponse.text(); let lines = dirListing.split("\n"); diff --git a/toolkit/modules/GMPInstallManager.jsm b/toolkit/modules/GMPInstallManager.jsm index 06f12c2f8988..4b1e3ff6c311 100644 --- a/toolkit/modules/GMPInstallManager.jsm +++ b/toolkit/modules/GMPInstallManager.jsm @@ -34,6 +34,11 @@ ChromeUtils.defineModuleGetter( "CertUtils", "resource://gre/modules/CertUtils.jsm" ); +ChromeUtils.defineModuleGetter( + this, + "FileUtils", + "resource://gre/modules/FileUtils.jsm" +); ChromeUtils.defineModuleGetter( this, "UpdateUtils", @@ -506,8 +511,10 @@ GMPAddon.prototype = { }; /** * Constructs a GMPExtractor object which is used to extract a GMP zip - * into the specified location. (Which typically leties per platform) + * into the specified location. * @param zipPath The path on disk of the zip file to extract + * @param relativePath The relative path inside the profile directory to + * extract the zip to. */ function GMPExtractor(zipPath, relativeInstallPath) { this.zipPath = zipPath; @@ -525,6 +532,9 @@ GMPExtractor.prototype = { this._deferred = PromiseUtils.defer(); let deferredPromise = this._deferred; let { zipPath, relativeInstallPath } = this; + // Escape the zip path since the worker will use it as a URI + let zipFile = new FileUtils.File(zipPath); + let zipURI = Services.io.newFileURI(zipFile).spec; let worker = new ChromeWorker( "resource://gre/modules/GMPExtractorWorker.js" ); @@ -532,17 +542,17 @@ GMPExtractor.prototype = { let log = getScopedLogger("GMPExtractor"); worker.terminate(); if (msg.data.result != "success") { - log.error("Failed to extract zip file: " + zipPath); + log.error("Failed to extract zip file: " + zipURI); return deferredPromise.reject({ target: this, status: msg.data.exception, type: "exception", }); } - log.info("Successfully extracted zip file: " + zipPath); + log.info("Successfully extracted zip file: " + zipURI); return deferredPromise.resolve(msg.data.extractedPaths); }; - worker.postMessage({ zipPath, relativeInstallPath }); + worker.postMessage({ zipURI, relativeInstallPath }); return this._deferred.promise; }, };