Bug 1170207 - allow overrides of chrome://../skin/ URIs with other chrome://../skin/ URIs within skin manifests, r=bsmedberg
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 01 Jun 2015 17:05:39 +0100
changeset 247568 264fb3d4d4c6df38e247e7ddd8d36f2758c3a02f
parent 247567 653299500d3c76dbf89284cad9c72290041beec2
child 247569 39821d952adc5d31bbee6233781abfa61b817034
push id60743
push usercbook@mozilla.com
push dateMon, 08 Jun 2015 10:03:01 +0000
treeherdermozilla-inbound@9ef529a9a02b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1170207
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1170207 - allow overrides of chrome://../skin/ URIs with other chrome://../skin/ URIs within skin manifests, r=bsmedberg
chrome/nsChromeRegistryChrome.cpp
xpcom/components/ManifestParser.cpp
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -942,16 +942,39 @@ nsChromeRegistryChrome::ManifestOverride
   nsCOMPtr<nsIURI> chromeuri = cx.ResolveURI(chrome);
   nsCOMPtr<nsIURI> resolveduri = cx.ResolveURI(resolved);
   if (!chromeuri || !resolveduri) {
     LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
                           "During chrome registration, unable to create URI.");
     return;
   }
 
+  if (cx.mType == NS_SKIN_LOCATION) {
+    bool chromeSkinOnly = false;
+    nsresult rv = chromeuri->SchemeIs("chrome", &chromeSkinOnly);
+    chromeSkinOnly = chromeSkinOnly && NS_SUCCEEDED(rv);
+    if (chromeSkinOnly) {
+      rv = resolveduri->SchemeIs("chrome", &chromeSkinOnly);
+      chromeSkinOnly = chromeSkinOnly && NS_SUCCEEDED(rv);
+    }
+    if (chromeSkinOnly) {
+      nsAutoCString chromePath, resolvedPath;
+      chromeuri->GetPath(chromePath);
+      resolveduri->GetPath(resolvedPath);
+      chromeSkinOnly = StringBeginsWith(chromePath, NS_LITERAL_CSTRING("/skin/")) &&
+                       StringBeginsWith(resolvedPath, NS_LITERAL_CSTRING("/skin/"));
+    }
+    if (!chromeSkinOnly) {
+      LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
+                            "Cannot register non-chrome://.../skin/ URIs '%s' and '%s' as overrides and/or to be overridden from a skin manifest.",
+                            chrome, resolved);
+      return;
+    }
+  }
+
   if (!CanLoadResource(resolveduri)) {
     LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
                           "Cannot register non-local URI '%s' for an override.", resolved);
     return;
   }
   mOverrideTable.Put(chromeuri, resolveduri);
 
   if (mDynamicRegistration) {
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -130,17 +130,19 @@ static const ManifestDirective kParsingT
     "overlay",          2, false, true, true, false, false,
     nullptr, &nsChromeRegistry::ManifestOverlay, nullptr
   },
   {
     "style",            2, false, false, true, false, false,
     nullptr, &nsChromeRegistry::ManifestStyle, nullptr
   },
   {
-    "override",         2, false, true, true, true, false,
+    // NB: note that while skin manifests can use this, they are only allowed
+    // to use it for chrome://../skin/ URLs
+    "override",         2, false, false, true, true, false,
     nullptr, &nsChromeRegistry::ManifestOverride, nullptr
   },
   {
     "resource",         2, false, true, true, true, false,
     nullptr, &nsChromeRegistry::ManifestResource, nullptr
   }
 };