From c023a51e604fb16f64f93a9ffb59bf18515d9033 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 10 Aug 2017 17:42:10 +0200 Subject: Crypto Services (utils) - Support for SHA224-512 --- netwerk/base/nsICryptoHash.idl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'netwerk') diff --git a/netwerk/base/nsICryptoHash.idl b/netwerk/base/nsICryptoHash.idl index cd865a3a9..ddd3103af 100644 --- a/netwerk/base/nsICryptoHash.idl +++ b/netwerk/base/nsICryptoHash.idl @@ -10,7 +10,7 @@ interface nsIInputStream; * This interface provides crytographic hashing algorithms. */ -[scriptable, uuid(1e5b7c43-4688-45ce-92e1-77ed931e3bbe)] +[scriptable, uuid(0a248513-dfa7-4474-8777-8c452d60dd04)] interface nsICryptoHash : nsISupports { /** @@ -25,6 +25,7 @@ interface nsICryptoHash : nsISupports const short SHA256 = 4; /* String value: "sha256" */ const short SHA384 = 5; /* String value: "sha384" */ const short SHA512 = 6; /* String value: "sha512" */ + const short SHA224 = 7; /* String value: "sha224" */ /** * Initialize the hashing object. This method may be -- cgit v1.2.3 From ef9aeb6a08749ecc43242ba523d67632a6ddc0dc Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 10 Aug 2017 23:16:51 +0200 Subject: Update UA construction. --- netwerk/protocol/http/nsHttpHandler.cpp | 63 +++++++++++++++++++++++++++------ netwerk/protocol/http/nsHttpHandler.h | 3 ++ 2 files changed, 56 insertions(+), 10 deletions(-) (limited to 'netwerk') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 1ddffabff..3c46bbf80 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -103,6 +103,9 @@ #define NS_HTTP_PROTOCOL_FLAGS (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE) +// Firefox compatibility version we claim in our UA by default +#define MOZILLA_COMPATVERSION "52.9" + //----------------------------------------------------------------------------- namespace mozilla { @@ -316,9 +319,11 @@ nsHttpHandler::Init() nsHttpChannelAuthProvider::InitializePrefs(); - mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION); + // rv: should have the Firefox/Gecko compatversion for web compatibility + mMisc.AssignLiteral("rv:" MOZILLA_COMPATVERSION); - mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION); + mCompatGecko.AssignLiteral("Gecko/20100101"); + mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_COMPATVERSION); nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); @@ -330,12 +335,30 @@ nsHttpHandler::Init() if (mAppName.Length() == 0) { appInfo->GetName(mAppName); } - appInfo->GetVersion(mAppVersion); mAppName.StripChars(R"( ()<>@,;:\"/[]?={})"); + } + + nsCString dynamicBuildID; + if (appInfo) { + appInfo->GetPlatformBuildID(dynamicBuildID); + if (dynamicBuildID.Length() > 8 ) + dynamicBuildID.Left(dynamicBuildID, 8); + } + + if (mAppVersionIsBuildID) { + // Override BuildID + mAppVersion.AssignLiteral(MOZ_UA_BUILDID); + } else if (appInfo) { + appInfo->GetVersion(mAppVersion); } else { - mAppVersion.AssignLiteral(MOZ_APP_UA_VERSION); + // Fall back to platform if appInfo is unavailable + mAppVersion.Assign(MOZILLA_UAVERSION); } + // If there's no override set, set it to the dynamic BuildID + if (mAppVersion.IsEmpty()) + mAppVersion.Assign(dynamicBuildID); + mSessionStartTime = NowInSeconds(); mHandlerActive = true; @@ -351,11 +374,11 @@ nsHttpHandler::Init() mRequestContextService = do_GetService("@mozilla.org/network/request-context-service;1"); -#if defined(ANDROID) || defined(MOZ_MULET) + // Goanna slice version mProductSub.AssignLiteral(MOZILLA_UAVERSION); -#else - mProductSub.AssignLiteral("20100101"); -#endif + + if (mProductSub.IsEmpty()) + mProductSub.Assign(dynamicBuildID); #if DEBUG // dump user agent prefs @@ -369,6 +392,7 @@ nsHttpHandler::Init() LOG(("> app-name = %s\n", mAppName.get())); LOG(("> app-version = %s\n", mAppVersion.get())); LOG(("> compat-firefox = %s\n", mCompatFirefox.get())); + LOG(("> compat-gecko = %s\n", mCompatGecko.get())); LOG(("> user-agent = %s\n", UserAgent().get())); #endif @@ -678,9 +702,10 @@ nsHttpHandler::BuildUserAgent() mAppName.Length() + mAppVersion.Length() + mCompatFirefox.Length() + + mCompatGecko.Length() + mCompatDevice.Length() + mDeviceModelId.Length() + - 13); + 14); // Application portion mUserAgent.Assign(mLegacyAppName); @@ -710,6 +735,12 @@ nsHttpHandler::BuildUserAgent() } mUserAgent += mMisc; mUserAgent += ')'; + + if(mCompatGeckoEnabled) { + // Provide frozen Gecko/20100101 slice + mUserAgent += ' '; + mUserAgent += mCompatGecko; + } // Product portion mUserAgent += ' '; @@ -719,7 +750,7 @@ nsHttpHandler::BuildUserAgent() bool isFirefox = mAppName.EqualsLiteral("Firefox"); if (isFirefox || mCompatFirefoxEnabled) { - // "Firefox/x.y" (compatibility) app token + // Provide "Firefox/x.y" (compatibility) app token mUserAgent += ' '; mUserAgent += mCompatFirefox; } @@ -966,6 +997,18 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) bool cVar = false; + if (PREF_CHANGED(UA_PREF("appVersionIsBuildID"))) { + rv = prefs->GetBoolPref(UA_PREF("appVersionIsBuildID"), &cVar); + mAppVersionIsBuildID = (NS_SUCCEEDED(rv) && cVar); + mUserAgentIsDirty = true; + } + + if (PREF_CHANGED(UA_PREF("compatMode.gecko"))) { + rv = prefs->GetBoolPref(UA_PREF("compatMode.gecko"), &cVar); + mCompatGeckoEnabled = (NS_SUCCEEDED(rv) && cVar); + mUserAgentIsDirty = true; + } + if (PREF_CHANGED(UA_PREF("compatMode.firefox"))) { rv = prefs->GetBoolPref(UA_PREF("compatMode.firefox"), &cVar); mCompatFirefoxEnabled = (NS_SUCCEEDED(rv) && cVar); diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 13cc72e8e..7121d4bc2 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -485,6 +485,9 @@ private: nsXPIDLCString mProductSub; nsXPIDLCString mAppName; nsXPIDLCString mAppVersion; + bool mAppVersionIsBuildID; + nsCString mCompatGecko; + bool mCompatGeckoEnabled; nsCString mCompatFirefox; bool mCompatFirefoxEnabled; nsXPIDLCString mCompatDevice; -- cgit v1.2.3 From 12640bf26e8a47293815670b03eec92a2965fcb6 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 11 Aug 2017 13:30:55 +0200 Subject: Read Firefox UA compatmode from a pref instead of hard-coded. In case of a missing pref, a hard-coded value is still used from the ctor. --- netwerk/protocol/http/nsHttpHandler.cpp | 30 +++++++++++++++++++++++------- netwerk/protocol/http/nsHttpHandler.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'netwerk') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 3c46bbf80..b94728b37 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -103,9 +103,6 @@ #define NS_HTTP_PROTOCOL_FLAGS (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE) -// Firefox compatibility version we claim in our UA by default -#define MOZILLA_COMPATVERSION "52.9" - //----------------------------------------------------------------------------- namespace mozilla { @@ -204,6 +201,7 @@ nsHttpHandler::nsHttpHandler() , mLegacyAppVersion("5.0") , mProduct("Gecko") , mCompatFirefoxEnabled(false) + , mCompatFirefoxVersion("52.9") , mUserAgentIsDirty(true) , mPromptTempRedirect(true) , mEnablePersistentHttpsCaching(false) @@ -320,10 +318,12 @@ nsHttpHandler::Init() nsHttpChannelAuthProvider::InitializePrefs(); // rv: should have the Firefox/Gecko compatversion for web compatibility - mMisc.AssignLiteral("rv:" MOZILLA_COMPATVERSION); + mMisc.AssignLiteral("rv:"); + mMisc += mCompatFirefoxVersion; mCompatGecko.AssignLiteral("Gecko/20100101"); - mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_COMPATVERSION); + mCompatFirefox.AssignLiteral("Firefox/"); + mCompatFirefox += mCompatFirefoxVersion; nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); @@ -352,7 +352,7 @@ nsHttpHandler::Init() appInfo->GetVersion(mAppVersion); } else { // Fall back to platform if appInfo is unavailable - mAppVersion.Assign(MOZILLA_UAVERSION); + mAppVersion.AssignLiteral(MOZILLA_UAVERSION); } // If there's no override set, set it to the dynamic BuildID @@ -1015,10 +1015,26 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) mUserAgentIsDirty = true; } + // general.useragent.compatMode.version + // This is the version number used in rv: for Gecko compatibility + // and in the Firefox/nn.nn slice when compatMode.firefox is enabled. + if (PREF_CHANGED(UA_PREF("compatMode.version"))) { + prefs->GetCharPref(UA_PREF("compatMode.version"), + getter_Copies(mCompatFirefoxVersion)); + + // rebuild mMisc and compatMode slice + mMisc.AssignLiteral("rv:"); + mMisc += mCompatFirefoxVersion; + mCompatFirefox.AssignLiteral("Firefox/"); + mCompatFirefox += mCompatFirefoxVersion; + + mUserAgentIsDirty = true; + } + // general.useragent.override if (PREF_CHANGED(UA_PREF("override"))) { prefs->GetCharPref(UA_PREF("override"), - getter_Copies(mUserAgentOverride)); + getter_Copies(mUserAgentOverride)); mUserAgentIsDirty = true; } diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 7121d4bc2..d51662db9 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -489,6 +489,7 @@ private: nsCString mCompatGecko; bool mCompatGeckoEnabled; nsCString mCompatFirefox; + nsCString mCompatFirefoxVersion; bool mCompatFirefoxEnabled; nsXPIDLCString mCompatDevice; nsCString mDeviceModelId; -- cgit v1.2.3 From 2e07719b3029db715d84fe0a292aae5832c6833c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 21 Feb 2018 21:42:05 +0100 Subject: Identify as Goanna + set Goanna platform version. --- netwerk/protocol/http/nsHttpHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'netwerk') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index b94728b37..67e29a029 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -199,7 +199,7 @@ nsHttpHandler::nsHttpHandler() , mSessionStartTime(0) , mLegacyAppName("Mozilla") , mLegacyAppVersion("5.0") - , mProduct("Gecko") + , mProduct("Goanna") , mCompatFirefoxEnabled(false) , mCompatFirefoxVersion("52.9") , mUserAgentIsDirty(true) -- cgit v1.2.3