Skip to content

Commit

Permalink
Re-enable referrers and fix fatal error
Browse files Browse the repository at this point in the history
Stale referrer information was being used because when a pending entry
existed, but its referrer was blank, it would wrongly use the active entry.

Fix brave/brave-browser#197

Auditors: @bridiver
  • Loading branch information
bbondy committed May 14, 2018
1 parent c9b4345 commit 693cf45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 0 additions & 3 deletions components/brave_shields/browser/brave_shields_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ bool ShouldSetReferrer(bool allow_referrers, bool shields_up,
const GURL& original_referrer, const GURL& tab_origin,
const GURL& target_url, const GURL& new_referrer_url,
blink::WebReferrerPolicy policy, Referrer *output_referrer) {
return false;
/*
if (!output_referrer ||
allow_referrers ||
!shields_up ||
Expand All @@ -131,7 +129,6 @@ bool ShouldSetReferrer(bool allow_referrers, bool shields_up,
*output_referrer = Referrer::SanitizeForRequest(target_url,
Referrer(new_referrer_url, policy));
return true;
*/
}

} // namespace brave_shields
16 changes: 10 additions & 6 deletions patches/content-browser-frame_host-navigation_request.cc.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index cc193622958b95baf7ae5b409c8c9e8df054a0ed..fc71a6067aeb261b91421a3d4349c8891ea7df1e 100644
index cc193622958b95baf7ae5b409c8c9e8df054a0ed..2b6bb2120c494cd04c01afb619cf186a31b9dbee 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -1362,6 +1362,18 @@ void NavigationRequest::CommitNavigation() {
@@ -1362,6 +1362,22 @@ void NavigationRequest::CommitNavigation() {
render_frame_host ==
frame_tree_node_->render_manager()->speculative_frame_host());

+ auto* pending_entry =
+ frame_tree_node_->navigator()->GetController()->GetPendingEntry();
+ if (pending_entry && !pending_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = pending_entry->GetReferrer();
+ if (pending_entry) {
+ if (!pending_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = pending_entry->GetReferrer();
+ }
+ } else {
+ auto* last_committed_entry =
+ frame_tree_node_->navigator()->GetController()->GetLastCommittedEntry();
+ if (last_committed_entry && !last_committed_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = last_committed_entry->GetReferrer();
+ if (last_committed_entry) {
+ if (!last_committed_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = last_committed_entry->GetReferrer();
+ }
+ }
+ }
+
Expand Down

0 comments on commit 693cf45

Please sign in to comment.