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

This commit is contained in:
Mark Pilgrim
2022-10-13 20:37:54 +02:00
committed by GitHub
parent 7c275266b3
commit 8db01cb30c
3 changed files with 13 additions and 3 deletions
+3 -2
View File
@@ -230,7 +230,8 @@ 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", "/");
@@ -238,7 +239,7 @@ IN_PROC_BROWSER_TEST_F(DebounceBrowserTest, SameSiteTracker) {
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,
+9 -1
View File
@@ -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>>,
@@ -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;
@@ -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);