summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2017-10-21 17:38:30 +0200
committerPale Moon <git-repo@palemoon.org>2017-10-21 17:38:30 +0200
commit2a18ead34a6d36af487eaec099a76d1898ea9967 (patch)
treeb826a0cab2656ccd43286ff857e8bac33e22211e
parentf9a610f1a42772aea7bc19baaa4947fdf8b1d0d5 (diff)
downloadpalemoon-gre-2a18ead34a6d36af487eaec099a76d1898ea9967.tar.gz
Improve logic of loadManifestFromZipReader.
- Explicitly throw. - Pass back the correct error message for install.rdf, not the webextension manifest. Tag #1396.
-rw-r--r--toolkit/mozapps/extensions/internal/XPIProvider.jsm25
1 files changed, 22 insertions, 3 deletions
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
index 2ec9948b7..1d62ce054 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -1063,21 +1063,40 @@ function loadManifestFromDir(aDir) {
* @param aZipReader
* An open nsIZipReader for the add-on's files
* @return an AddonInternal object
- * @throws if the XPI file does not contain a valid install manifest
+ * @throws if the XPI file does not contain a valid install manifest.
+ * Throws with |webext:true| if a WebExtension manifest was found
+ * to distinguish between WebExtensions and corrupt files.
*/
function loadManifestFromZipReader(aZipReader) {
let zis;
try {
zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST);
} catch (e) {
- let zws = aZipReader.getInputStream(FILE_WEBEXT_MANIFEST);
- zws.close();
+ // We're going to throw here, but depending on whether we have a
+ // WebExtension manifest in the XPI, we'll throw with the webext flag.
+ try {
+ let zws = aZipReader.getInputStream(FILE_WEBEXT_MANIFEST);
+ zws.close();
+ } catch(e2) {
+ // We have neither an install manifest nor a WebExtension manifest;
+ // this means the extension file has a structural problem.
+ // Just pass the original error up the chain in that case.
+ throw {
+ name: e.name,
+ message: e.message
+ };
+ }
+ // If we get here, we have a WebExtension manifest but no install
+ // manifest. Pass the error up the chain with the webext flag.
throw {
name: e.name,
message: e.message,
webext: true
};
}
+
+ // We found an install manifest, so it's either a regular or hybrid
+ // extension. Continue processing.
let bis = Cc["@mozilla.org/network/buffered-input-stream;1"].
createInstance(Ci.nsIBufferedInputStream);
bis.init(zis, 4096);