Skip to content

Commit

Permalink
Strip referrer header in xorigin requests from .onion (fixes brave/br…
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarier committed Oct 26, 2021
1 parent ef69571 commit dce3d8c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chromium_src/net/url_request/url_request_job.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Copyright 2021 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */

#define BRAVE_COMPUTE_REFERRER_FOR_POLICY \
if (!same_origin && base::EndsWith(original_referrer.host_piece(), ".onion", \
base::CompareCase::INSENSITIVE_ASCII)) { \
policy = ReferrerPolicy::NO_REFERRER; \
}

#include "../../../../net/url_request/url_request_job.cc"
#undef BRAVE_COMPUTE_REFERRER_FOR_POLICY
12 changes: 12 additions & 0 deletions patches/net-url_request-url_request_job.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index b2458b8037589a46fd86af21f79fb7ac13308b5f..d508eff7345937d6ee7aefd6d395e26f0b8f3801 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -316,6 +316,7 @@ GURL URLRequestJob::ComputeReferrerForPolicy(

bool same_origin = url::Origin::Create(original_referrer)
.IsSameOriginWith(url::Origin::Create(destination));
+ BRAVE_COMPUTE_REFERRER_FOR_POLICY

if (same_origin_out_for_metrics)
*same_origin_out_for_metrics = same_origin;

0 comments on commit dce3d8c

Please sign in to comment.