summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <git-repo@palemoon.org>2020-03-15 17:34:46 +0100
committerGitHub <noreply@github.com>2020-03-15 17:34:46 +0100
commit60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2 (patch)
treea759eae919d115b256ac6d72a5e0e6d1b9613eee
parenta1f53ada594eb96d0b1275a58c6b29d3f1ecd027 (diff)
parenta20f208834b87dfdd10dee3267056a8492a2b649 (diff)
downloadUXP-60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2.tar
UXP-60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2.tar.gz
UXP-60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2.tar.lz
UXP-60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2.tar.xz
UXP-60ea1e85f522720e5d8cf07528f59c4f1cb9ebe2.zip
Merge pull request #1484 from JustOff/PR_ssuao_priority
Give dynamic SSUAO rules priority over static ones
-rw-r--r--netwerk/protocol/http/UserAgentOverrides.jsm26
1 files changed, 19 insertions, 7 deletions
diff --git a/netwerk/protocol/http/UserAgentOverrides.jsm b/netwerk/protocol/http/UserAgentOverrides.jsm
index aa1325a64..425bdfd72 100644
--- a/netwerk/protocol/http/UserAgentOverrides.jsm
+++ b/netwerk/protocol/http/UserAgentOverrides.jsm
@@ -30,6 +30,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
var gPrefBranch;
var gOverrides = new Map;
var gUpdatedOverrides;
+var gOldDynOverrides;
var gOverrideForHostCache = new Map;
var gInitialized = false;
var gOverrideFunctions = [
@@ -55,7 +56,10 @@ this.UserAgentOverrides = {
}
UserAgentUpdates.init(function(overrides) {
- gOverrideForHostCache.clear();
+ if (overrides == gOldDynOverrides) {
+ return;
+ }
+ gOldDynOverrides = overrides;
if (overrides) {
for (let domain in overrides) {
overrides[domain] = getUserAgentFromOverride(overrides[domain]);
@@ -63,6 +67,7 @@ this.UserAgentOverrides = {
overrides.get = function(key) { return this[key]; };
}
gUpdatedOverrides = overrides;
+ buildOverrides();
});
buildOverrides();
@@ -159,15 +164,22 @@ function buildOverrides() {
if (!Services.prefs.getBoolPref(PREF_OVERRIDES_ENABLED))
return;
- let builtUAs = new Map;
let domains = gPrefBranch.getChildList("");
+ // Since the static override map has the highest priority, we build it so
+ // that it includes only domains with user-set overrides and domains with
+ // default pre-set overrides that are not overridden by dynamic updates.
for (let domain of domains) {
- let override = gPrefBranch.getCharPref(domain);
- let userAgent = getUserAgentFromOverride(override);
-
- if (userAgent != DEFAULT_UA) {
- gOverrides.set(domain, userAgent);
+ if (!(gUpdatedOverrides && gUpdatedOverrides.get(domain)) ||
+ gPrefBranch.prefHasUserValue(domain)) {
+ // Here we selected domains that are not dynamically overridden
+ // or have a user-set override.
+ let override = gPrefBranch.getCharPref(domain);
+ let userAgent = getUserAgentFromOverride(override);
+
+ if (userAgent != DEFAULT_UA) {
+ gOverrides.set(domain, userAgent);
+ }
}
}
}