Add "Ubuntu" to the platform part of the UA string

Forwarded: not-needed

Gbp-Pq: Name ubuntu-ua-string-changes.patch
This commit is contained in:
Chris Coulson 2022-07-12 19:55:04 +08:00 committed by Lu zhiping
parent a82bc5270d
commit 1689cdee77
5 changed files with 30 additions and 1 deletions

View File

@ -97,6 +97,7 @@ def old_configure_options(*options):
"--with-branding",
"--with-distribution-id",
"--with-macbundlename-prefix",
"--with-ua-vendor",
"--x-includes",
"--x-libraries",
)

View File

@ -216,4 +216,7 @@ if CONFIG["OS_TARGET"] == "Darwin":
elif CONFIG["HOST_MAJOR_VERSION"] >= "15":
DEFINES["HAS_CONNECTX"] = True
if CONFIG["MOZ_UA_VENDOR"]:
DEFINES["MOZ_UA_VENDOR"] = "\"%s\"" % CONFIG["MOZ_UA_VENDOR"]
include("/tools/fuzzing/libfuzzer-config.mozbuild")

View File

@ -412,6 +412,9 @@ nsresult nsHttpHandler::Init() {
LOG(("> misc = %s\n", mMisc.get()));
LOG(("> product = %s\n", mProduct.get()));
LOG(("> product-sub = %s\n", mProductSub.get()));
#ifdef MOZ_UA_VENDOR
LOG(("> vendor = %s\n", mVendor.get()));
#endif
LOG(("> app-name = %s\n", mAppName.get()));
LOG(("> app-version = %s\n", mAppVersion.get()));
LOG(("> compat-firefox = %s\n", mCompatFirefox.get()));
@ -746,7 +749,11 @@ void nsHttpHandler::BuildUserAgent() {
mOscpu.Length() + mMisc.Length() + mProduct.Length() +
mProductSub.Length() + mAppName.Length() +
mAppVersion.Length() + mCompatFirefox.Length() +
mCompatDevice.Length() + mDeviceModelId.Length() + 13);
mCompatDevice.Length() + mDeviceModelId.Length() +
#ifdef MOZ_UA_VENDOR
mVendor.Length() +
#endif
15);
// Application portion
mUserAgent.Assign(mLegacyAppName);
@ -761,6 +768,10 @@ void nsHttpHandler::BuildUserAgent() {
mUserAgent += mPlatform;
mUserAgent.AppendLiteral("; ");
}
#endif
#ifdef MOZ_UA_VENDOR
mUserAgent += mVendor;
mUserAgent.AppendLiteral("; ");
#endif
if (!mCompatDevice.IsEmpty()) {
mUserAgent += mCompatDevice;

View File

@ -625,6 +625,9 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
// useragent components
nsCString mLegacyAppName{"Mozilla"};
nsCString mLegacyAppVersion{"5.0"};
#ifdef MOZ_UA_VENDOR
nsCString mVendor{MOZ_UA_VENDOR};
#endif
nsCString mPlatform;
nsCString mOscpu;
nsCString mMisc;

View File

@ -983,6 +983,16 @@ else
AC_MSG_RESULT([no])
fi
# Allow someone to add a vendor component to the default user agent string
MOZ_ARG_WITH_STRING(ua-vendor,
[--with-ua-vendor=VENDOR sets MOZ_UA_VENDOR to VENDOR],
WITH_UA_VENDOR=$withval,
)
if test -n "$WITH_UA_VENDOR" ; then
MOZ_UA_VENDOR="$WITH_UA_VENDOR"
fi
AC_SUBST(MOZ_OFFICIAL_BRANDING)
if test -n "$MOZ_OFFICIAL_BRANDING"; then
if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
@ -1270,6 +1280,7 @@ fi
AC_SUBST(MOZ_APP_DISPLAYNAME)
AC_SUBST(MOZ_APP_VENDOR)
AC_SUBST(MOZ_UA_VENDOR)
AC_SUBST(MOZ_APP_PROFILE)
AC_SUBST(MOZ_APP_ID)
AC_SUBST(MAR_CHANNEL_ID)