From f596e3d581a6f69fb3842a68378f49ad444d5c66 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Tue, 9 Jul 2024 14:08:03 +0800 Subject: [PATCH] UAO: correct UA string rebuild code, add platform_version pref. --- modules/libpref/init/all.js | 1 + netwerk/protocol/http/nsHttpHandler.cpp | 32 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 039b6ceea9..08613f5d1c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -28,6 +28,7 @@ pref("general.useragent.compatMode.firefox", false); pref("general.useragent.compatMode.version", "102.0"); pref("general.useragent.appVersionIsBuildID", false); pref("general.useragent.change_platform_version", true); +pref("general.useragent.platform_version", "6.6"); // In order to disable all overrides by default, don't initialize // UserAgentOverrides.jsm. diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index d4ea8c6f9a..db92ba75c9 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -948,9 +948,35 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) rv = prefs->GetBoolPref(UA_PREF("change_platform_version"), &cVar); mCompatPlatformEnabled = (NS_SUCCEEDED(rv) && cVar); - // Rebuild application version string. - BuildAppVersion(); - + // Rebuild rv: and Goanna slice version + mMisc.AssignLiteral("rv:"); + if (mCompatGeckoEnabled) { + mMisc += mCompatFirefoxVersion; + } else { + if (mCompatPlatformEnabled) { + mMisc += mCompatPlatformVersion; + } else { + mMisc += MOZILLA_UAVERSION; + } + } + + if (mCompatGeckoEnabled) { + if (mCompatPlatformEnabled) { + mProductSub.Assign(mCompatPlatformVersion); + } else { + mProductSub.AssignLiteral(MOZILLA_UAVERSION); + } + } else { + if (mCompatPlatformEnabled) { + mProductSub.Assign(mCompatPlatformVersion); + } else { + mProductSub.Assign(mAppBuildID); + } + } + // In case MOZILLA_UAVERSION is empty for some odd reason... + if (mProductSub.IsEmpty()) { + mProductSub.Assign(mAppBuildID); + } mUserAgentIsDirty = true; } // general.useragent.platform_version