From ad6bd576e5f7cf38759b545b3de03e3bd418e644 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Mon, 1 Jun 2015 17:05:39 +0100 Subject: [PATCH] Bug 1170207 - allow overrides of chrome://../skin/ URIs with other chrome://../skin/ URIs within skin manifests, r=bsmedberg --- chrome/nsChromeRegistryChrome.cpp | 23 +++++++++++++++++++++++ xpcom/components/ManifestParser.cpp | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/chrome/nsChromeRegistryChrome.cpp b/chrome/nsChromeRegistryChrome.cpp index 935a01ff4c9..9d83da94b77 100644 --- a/chrome/nsChromeRegistryChrome.cpp +++ b/chrome/nsChromeRegistryChrome.cpp @@ -947,6 +947,29 @@ nsChromeRegistryChrome::ManifestOverride(ManifestProcessingContext& cx, int line 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); diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index ffd31e0a1c1..2341fa11b0a 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -135,7 +135,9 @@ static const ManifestDirective kParsingTable[] = { 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 }, {