Bug 1559747 - Part 2: UA string needn't reveal the user is running 32-bit Firefox on Win64 OS. r=tjr
authorChris Peterson <cpeterson@mozilla.com>
Wed, 19 Jun 2019 09:56:50 +0000
changeset 479291 ef0e2b8429328d53cefee4ce64ab6b3cd2df937c
parent 479290 dcd234c04764821fc4fd93a06285f0df66392eef
child 479292 a440f0629814ea638bdbee6cf2f1a0425dd04c61
child 479293 71d648e912ef3e45b9faf3c63894152e1874c037
push id36177
push userrmaries@mozilla.com
push dateThu, 20 Jun 2019 09:46:31 +0000
treeherdermozilla-central@a440f0629814 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstjr
bugs1559747, 444770, 265536
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559747 - Part 2: UA string needn't reveal the user is running 32-bit Firefox on Win64 OS. r=tjr Change the User-Agent HTTP header and the navigator.userAgent, navigator.platform, and navigator.oscpu APIs to say "Win64" instead "WOW64" (bug 444770) when the user is running 32-bit Firefox on Win64 OS. Software download websites that try to sniff for the user's CPU architecture (so they can serve compatible software) only need to know whether the user has a 32- or 64-bit OS, not whether they are running a 32- or 64-bit Firefox build. Once upon a time, Mozilla's Plugin Finder Service needed to check whether Firefox was 32- or 64-bit so it could direct the user to a Flash Player plugin compatible with their Firefox build (bug 265536). But these days Adobe's Flash Player installer includes both 32- and 64-bit plugins. Depends on D35164 Differential Revision: https://phabricator.services.mozilla.com/D35165
netwerk/protocol/http/nsHttpHandler.cpp
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -935,18 +935,18 @@ void nsHttpHandler::BuildUserAgent() {
     mUserAgent += ' ';
     mUserAgent += mAppName;
     mUserAgent += '/';
     mUserAgent += mAppVersion;
   }
 }
 
 #ifdef XP_WIN
-#  define WNT_BASE "Windows NT %ld.%ld"
-#  define W64_PREFIX "; Win64"
+#  define OSCPU_WINDOWS "Windows NT %ld.%ld"
+#  define OSCPU_WIN64 OSCPU_WINDOWS "; Win64; x64"
 #endif
 
 void nsHttpHandler::InitUserAgentComponents() {
 #ifndef MOZ_UA_OS_AGNOSTIC
   // Gather platform.
   mPlatform.AssignLiteral(
 #  if defined(ANDROID)
       "Android"
@@ -1012,28 +1012,28 @@ void nsHttpHandler::InitUserAgentCompone
 #ifndef MOZ_UA_OS_AGNOSTIC
   // Gather OS/CPU.
 #  if defined(XP_WIN)
   OSVERSIONINFO info = {sizeof(OSVERSIONINFO)};
 #    pragma warning(push)
 #    pragma warning(disable : 4996)
   if (GetVersionEx(&info)) {
 #    pragma warning(pop)
+
     const char* format;
-#    if defined _M_IA64
-    format = WNT_BASE W64_PREFIX "; IA64";
-#    elif defined _M_X64 || defined _M_AMD64
-    format = WNT_BASE W64_PREFIX "; x64";
+#    if defined _M_X64 || defined _M_AMD64
+    format = OSCPU_WIN64;
 #    else
     BOOL isWow64 = FALSE;
     if (!IsWow64Process(GetCurrentProcess(), &isWow64)) {
       isWow64 = FALSE;
     }
-    format = isWow64 ? WNT_BASE "; WOW64" : WNT_BASE;
+    format = isWow64 ? OSCPU_WIN64 : OSCPU_WINDOWS;
 #    endif
+
     SmprintfPointer buf =
         mozilla::Smprintf(format, info.dwMajorVersion, info.dwMinorVersion);
     if (buf) {
       mOscpu = buf.get();
     }
   }
 #  elif defined(XP_MACOSX)
 #    if defined(__ppc__)