Bug 1591226 - Convert network.http.referer.hideOnionSource to a static pref. r=njn

Converts network.http.referer.hideOnionSource to a static pref and removes its mirror variable and varcache pref definition.

Differential Revision: https://phabricator.services.mozilla.com/D50534

--HG--
extra : moz-landing-system : lando
This commit is contained in:
kriswright 2019-10-25 04:16:29 +00:00
Родитель f634517db3
Коммит 9ac026787f
6 изменённых файлов: 12 добавлений и 20 удалений

Просмотреть файл

@ -60,7 +60,6 @@ static uint32_t sDefaultTrackerRp = DEFAULT_TRACKER_RP;
static uint32_t defaultPrivateRp = DEFAULT_PRIVATE_RP;
static uint32_t defaultTrackerPrivateRp = DEFAULT_TRACKER_PRIVATE_RP;
static bool sUserHideOnionReferrerSource = false;
static uint32_t sUserReferrerSendingPolicy = 0;
static uint32_t sUserXOriginSendingPolicy = 0;
static uint32_t sUserTrimmingPolicy = 0;
@ -73,8 +72,6 @@ static void CachePreferrenceValue() {
return;
}
Preferences::AddBoolVarCache(&sUserHideOnionReferrerSource,
"network.http.referer.hideOnionSource");
Preferences::AddUintVarCache(&sUserReferrerSendingPolicy,
"network.http.sendRefererHeader");
Preferences::AddUintVarCache(&sReferrerHeaderLimit,
@ -116,12 +113,6 @@ static void CachePreferrenceValue() {
sPrefCached = true;
}
/* static */
bool ReferrerInfo::HideOnionReferrerSource() {
CachePreferrenceValue();
return sUserHideOnionReferrerSource;
}
struct LegacyReferrerPolicyTokenMap {
const char* mToken;
ReferrerPolicy mPolicy;
@ -369,7 +360,8 @@ nsresult ReferrerInfo::HandleUserXOriginSendingPolicy(nsIURI* aURI,
}
// Send an empty referrer if xorigin and leaving a .onion domain.
if (sUserHideOnionReferrerSource && !uriHost.Equals(referrerHost) &&
if (StaticPrefs::network_http_referer_hideOnionSource() &&
!uriHost.Equals(referrerHost) &&
StringEndsWith(referrerHost, NS_LITERAL_CSTRING(".onion"))) {
return NS_OK;
}

Просмотреть файл

@ -161,12 +161,6 @@ class ReferrerInfo : public nsIReferrerInfo {
*/
static bool ShouldResponseInheritReferrerInfo(nsIChannel* aChannel);
/*
* Check whether we need to hide referrer when leaving a .onion domain.
* Controlled by user pref: network.http.referer.hideOnionSource
*/
static bool HideOnionReferrerSource();
/*
* Check whether referrer is allowed to send in secure to insecure scenario.
*/

Просмотреть файл

@ -6415,6 +6415,13 @@
value: false
mirror: always
# Check whether we need to hide referrer when leaving a .onion domain.
# false=allow onion referer, true=hide onion referer (use empty referer).
- name: network.http.referer.hideOnionSource
type: bool
value: false
mirror: always
# Enables the predictive service.
- name: network.predictor.enabled
type: bool

Просмотреть файл

@ -1347,8 +1347,6 @@ pref("network.http.referer.defaultPolicy.pbmode", 2);
// No need to change this pref for trimming referrers from trackers since in
// private windows we already trim all referrers to origin only.
pref("network.http.referer.defaultPolicy.trackers.pbmode", 2);
// false=allow onion referer, true=hide onion referer (use empty referer)
pref("network.http.referer.hideOnionSource", false);
// 0=full URI, 1=scheme+host+port+path, 2=scheme+host+port
pref("network.http.referer.trimmingPolicy", 0);
// 0=full URI, 1=scheme+host+port+path, 2=scheme+host+port

Просмотреть файл

@ -44,6 +44,7 @@
#include "mozilla/NullPrincipal.h"
#include "nsIHttpHeaderVisitor.h"
#include "nsQueryObject.h"
#include "mozilla/StaticPrefs_network.h"
#include <algorithm>
using namespace mozilla;
@ -964,7 +965,7 @@ nsresult nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
NS_ENSURE_TRUE(http, NS_ERROR_FAILURE);
// hide the Origin header when requesting from .onion and requesting CORS
if (dom::ReferrerInfo::HideOnionReferrerSource()) {
if (StaticPrefs::network_http_referer_hideOnionSource()) {
nsCOMPtr<nsIURI> potentialOnionUri; // the candidate uri in header Origin:
rv = mOriginHeaderPrincipal->GetURI(getter_AddRefs(potentialOnionUri));
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -9800,7 +9800,7 @@ void nsHttpChannel::SetOriginHeader() {
// Origin header suppressed by user setting
return;
}
} else if (dom::ReferrerInfo::HideOnionReferrerSource()) {
} else if (StaticPrefs::network_http_referer_hideOnionSource()) {
nsAutoCString host;
if (referrer && NS_SUCCEEDED(referrer->GetAsciiHost(host)) &&
StringEndsWith(host, NS_LITERAL_CSTRING(".onion"))) {