Bug 1355334 Bail out immediately on manifest errors when parsing a webextension r?kmag draft
authorAndrew Swan <aswan@mozilla.com>
Mon, 10 Apr 2017 21:04:43 -0700
changeset 560863 5e978be9f5167dc7529b5b961bed79c11d247ad2
parent 559749 b1364675bdf5dffe63fd60373034293de0b513d5
child 623821 b0b0826ca0f7a04ec4f064b83f2e218699325df9
push id53563
push useraswan@mozilla.com
push dateWed, 12 Apr 2017 01:18:36 +0000
reviewerskmag
bugs1355334
milestone55.0a1
Bug 1355334 Bail out immediately on manifest errors when parsing a webextension r?kmag MozReview-Commit-ID: LdwimNj1upZ
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -958,25 +958,27 @@ function getRDFProperty(aDs, aResource, 
 var loadManifestFromWebManifest = Task.async(function*(aUri) {
   // We're passed the URI for the manifest file. Get the URI for its
   // parent directory.
   let uri = NetUtil.newURI("./", null, aUri);
 
   let extension = new ExtensionData(uri);
 
   let manifest = yield extension.loadManifest();
-  let theme = !!manifest.theme;
 
   // Read the list of available locales, and pre-load messages for
   // all locales.
-  let locales = yield extension.initAllLocales();
-
-  // If there were any errors loading the extension, bail out now.
-  if (extension.errors.length)
+  let locales = (extension.errors.length == 0) ?
+                yield extension.initAllLocales() : null;
+
+  if (extension.errors.length > 0) {
     throw new Error("Extension is invalid");
+  }
+
+  let theme = Boolean(manifest.theme);
 
   let bss = (manifest.browser_specific_settings && manifest.browser_specific_settings.gecko)
       || (manifest.applications && manifest.applications.gecko) || {};
   if (manifest.browser_specific_settings && manifest.applications) {
     logger.warn("Ignoring applications property in manifest");
   }
 
   // A * is illegal in strict_min_version