Bug 1693295 - Cap the Windows version in the User-Agent to 10.0. r=cpeterson

Differential Revision: https://phabricator.services.mozilla.com/D105605
This commit is contained in:
Henri Sivonen 2021-02-22 08:56:40 +00:00
parent d3c41e5679
commit 37e52696cd
2 changed files with 16 additions and 0 deletions

View File

@ -70,6 +70,10 @@ const SPOOFED_PLATFORM = {
other: "Linux x86_64",
};
// If comparison with this value fails in the future,
// it's time to evaluate if exposing a new Windows
// version to the Web is appropriate. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=1693295
const WindowsOscpu =
cpuArch == "x86_64"
? `Windows NT ${osVersion}; Win64; x64`

View File

@ -951,6 +951,18 @@ void nsHttpHandler::InitUserAgentComponents() {
if (GetVersionEx(&info)) {
# pragma warning(pop)
if (info.dwMajorVersion >= 10) {
// Cap the reported Windows version to 10.0. This way, Microsoft doesn't
// get to change Web compat-sensitive values without our veto. The
// compat-sensitivity keeps going up as 10.0 stays as the current value
// for longer and longer. If the system-reported version ever changes,
// we'll be able to take our time to evaluate the Web compat impact
// instead of having to scamble to react like happened with macOS
// changing from 10.x to 11.x.
info.dwMajorVersion = 10;
info.dwMinorVersion = 0;
}
const char* format;
# if defined _M_X64 || defined _M_AMD64
format = OSCPU_WIN64;