Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change debounce behavior to never debounce to same eTLD+1 #15392

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions browser/debounce/debounce_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ IN_PROC_BROWSER_TEST_F(DebounceBrowserTest, QuadRedirect) {
}

// Test a redirect chain that bounces from a tracker to a final URL in the
// tracker's domain.
// tracker's domain. This should NOT be debounced, because the tracker and
// the final URL share an eTLD+1.
IN_PROC_BROWSER_TEST_F(DebounceBrowserTest, SameSiteTracker) {
ASSERT_TRUE(InstallMockExtension());
GURL final_url = embedded_test_server()->GetURL("z.com", "/");
GURL intermediate_url = add_redirect_param(
embedded_test_server()->GetURL("tracker.z.com", "/"), final_url);
GURL start_url = add_redirect_param(
embedded_test_server()->GetURL("origin.h.com", "/"), intermediate_url);
NavigateToURLAndWaitForRedirects(start_url, final_url);
NavigateToURLAndWaitForRedirects(start_url, intermediate_url);
}

// Test a long redirect chain that bounces through the original URL's domain,
Expand Down
10 changes: 9 additions & 1 deletion components/debounce/browser/debounce_rule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ const std::string DebounceRule::GetETLDForDebounce(const std::string& host) {
EXCLUDE_PRIVATE_REGISTRIES);
}

// static
bool DebounceRule::IsSameETLDForDebounce(const GURL& url1, const GURL& url2) {
return net::registry_controlled_domains::SameDomainOrHost(
url1, url2,
net::registry_controlled_domains::PrivateRegistryFilter::
EXCLUDE_PRIVATE_REGISTRIES);
}

// static
base::expected<std::pair<std::vector<std::unique_ptr<DebounceRule>>,
base::flat_set<std::string>>,
Expand Down Expand Up @@ -308,7 +316,7 @@ bool DebounceRule::Apply(const GURL& original_url,
return false;

// Failsafe: never redirect to the same site.
if (url::IsSameOriginWith(original_url, new_url))
if (IsSameETLDForDebounce(original_url, new_url))
return false;

*final_url = new_url;
Expand Down
1 change: 1 addition & 0 deletions components/debounce/browser/debounce_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class DebounceRule {
std::string>
ParseRules(const std::string& contents);
static const std::string GetETLDForDebounce(const std::string& host);
static bool IsSameETLDForDebounce(const GURL& url1, const GURL& url2);
static bool GetURLPatternSetFromValue(const base::Value* value,
extensions::URLPatternSet* result);

Expand Down