summaryrefslogtreecommitdiffstats
path: root/netwerk
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2020-03-12 21:37:13 +0200
committerJustOff <Off.Just.Off@gmail.com>2020-03-15 13:41:46 +0200
commita20f208834b87dfdd10dee3267056a8492a2b649 (patch)
treeec21e8620c959ed06846794248f6b7a16471d2d1 /netwerk
parent41e5925b4271c598601fdc77238bbf6497576594 (diff)
downloadUXP-a20f208834b87dfdd10dee3267056a8492a2b649.tar
UXP-a20f208834b87dfdd10dee3267056a8492a2b649.tar.gz
UXP-a20f208834b87dfdd10dee3267056a8492a2b649.tar.lz
UXP-a20f208834b87dfdd10dee3267056a8492a2b649.tar.xz
UXP-a20f208834b87dfdd10dee3267056a8492a2b649.zip
Issue #1482 - Give dynamic SSUAO rules priority over static ones
Diffstat (limited to 'netwerk')
-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);
+ }
}
}
}