Skip to content
Snippets Groups Projects
Verified Commit 8338a3c3 authored by Tom Ritter's avatar Tom Ritter Committed by Pier Angelo Vendrame
Browse files

Bug 1873526: Refactor the restriction override list from a big if statement to a list r=KrisWright

parent f260c6bd
Branches
Tags
1 merge request!1061Bug 42998: Rebased stable onto 115.14.0esr
......@@ -6024,7 +6024,8 @@ struct PrefListEntry {
// StaticPrefList.yml), a string pref, and it is NOT exempted in
// sDynamicPrefOverrideList
//
// This behavior is codified in ShouldSanitizePreference() below
// This behavior is codified in ShouldSanitizePreference() below.
// Exclusions of preferences can be defined in sOverrideRestrictionsList[].
static const PrefListEntry sRestrictFromWebContentProcesses[] = {
// Remove prefs with user data
PREF_LIST_ENTRY("datareporting.policy."),
......@@ -6073,6 +6074,15 @@ static const PrefListEntry sRestrictFromWebContentProcesses[] = {
PREF_LIST_ENTRY("toolkit.telemetry.previousBuildID"),
};
// Allowlist for prefs and branches blocklisted in
// sRestrictFromWebContentProcesses[], including prefs from
// StaticPrefList.yaml and *.js, to let them pass.
static const PrefListEntry sOverrideRestrictionsList[]{
PREF_LIST_ENTRY("services.settings.clock_skew_seconds"),
PREF_LIST_ENTRY("services.settings.last_update_seconds"),
PREF_LIST_ENTRY("services.settings.server"),
};
// These prefs are dynamically-named (i.e. not specified in prefs.js or
// StaticPrefList) and would normally by blocklisted but we allow them through
// anyway, so this override list acts as an allowlist
......@@ -6168,10 +6178,12 @@ static bool ShouldSanitizePreference(const Pref* const aPref) {
// pref through.
for (const auto& entry : sRestrictFromWebContentProcesses) {
if (strncmp(entry.mPrefBranch, prefName, entry.mLen) == 0) {
const auto* p = prefName; // This avoids clang-format doing ugly things.
return !(strncmp("services.settings.clock_skew_seconds", p, 36) == 0 ||
strncmp("services.settings.last_update_seconds", p, 37) == 0 ||
strncmp("services.settings.server", p, 24) == 0);
for (const auto& pasEnt : sOverrideRestrictionsList) {
if (strncmp(pasEnt.mPrefBranch, prefName, pasEnt.mLen) == 0) {
return false;
}
}
return true;
}
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment