summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2020-03-12 21:37:13 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 13:06:30 +0200
commitf7388678bd1dd3133e2ab6e6a06e37ad4f3b62be (patch)
tree2eda2fdd9a1437d56c788183e9b3746ef2d7fc8f
parentb45f5c435eff41ac12d234f31432463e87c58bb9 (diff)
downloadUXP-f7388678bd1dd3133e2ab6e6a06e37ad4f3b62be.tar
UXP-f7388678bd1dd3133e2ab6e6a06e37ad4f3b62be.tar.gz
UXP-f7388678bd1dd3133e2ab6e6a06e37ad4f3b62be.tar.lz
UXP-f7388678bd1dd3133e2ab6e6a06e37ad4f3b62be.tar.xz
UXP-f7388678bd1dd3133e2ab6e6a06e37ad4f3b62be.zip
Issue #1482 - 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);
+ }
}
}
}