mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1555439
: Store enterprise policy about: whitelist in static array. r=mkaply
Differential Revision: https://phabricator.services.mozilla.com/D33058 --HG-- extra : rebase_source : 68ee1c16d2008a3766faad2b661788ee0a381db1
This commit is contained in:
parent
4693e3507d
commit
ffe2477ea3
@ -165,6 +165,26 @@ nsresult nsAboutProtocolHandler::CreateNewURI(const nsACString& aSpec,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The list of about: paths which are always allowed, regardless of enterprise
|
||||
// policies.
|
||||
//
|
||||
// Note: This is stored as a two-dimensional array, with each element the size
|
||||
// of the longest string in the list, for space efficiency. An array of
|
||||
// character pointers would consume more space than the extra padding in
|
||||
// shorter strings, and would require per-process relocations at load time.
|
||||
//
|
||||
// Important: This list MUST be kept sorted!
|
||||
static const char kAboutPageEnterpriseWhitelist[][10] = {
|
||||
// clang-format off
|
||||
"blank",
|
||||
"certerror",
|
||||
"home",
|
||||
"neterror",
|
||||
"newtab",
|
||||
"welcome",
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAboutProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
|
||||
nsIChannel** result) {
|
||||
@ -178,17 +198,18 @@ nsAboutProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
|
||||
nsAutoCString path;
|
||||
nsresult rv2 = NS_GetAboutModuleName(uri, path);
|
||||
if (NS_SUCCEEDED(rv2)) {
|
||||
size_t matchIdx;
|
||||
if (path.EqualsLiteral("srcdoc")) {
|
||||
// about:srcdoc is meant to be unresolvable, yet is included in the
|
||||
// about lookup tables so that it can pass security checks when used in
|
||||
// a srcdoc iframe. To ensure that it stays unresolvable, we pretend
|
||||
// that it doesn't exist.
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
} else if (!path.EqualsLiteral("blank") &&
|
||||
!path.EqualsLiteral("neterror") && !path.EqualsLiteral("home") &&
|
||||
!path.EqualsLiteral("welcome") &&
|
||||
!path.EqualsLiteral("newtab") &&
|
||||
!path.EqualsLiteral("certerror")) {
|
||||
} else if (!BinarySearchIf(
|
||||
kAboutPageEnterpriseWhitelist, 0,
|
||||
ArrayLength(kAboutPageEnterpriseWhitelist),
|
||||
[&path](const char* aOther) { return path.Compare(aOther); },
|
||||
&matchIdx)) {
|
||||
nsCOMPtr<nsIEnterprisePolicies> policyManager =
|
||||
do_GetService("@mozilla.org/enterprisepolicies;1", &rv2);
|
||||
if (NS_SUCCEEDED(rv2)) {
|
||||
|
Loading…
Reference in New Issue
Block a user