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

Exempt Proofpoint's redirector from query string modifications #25642

Merged
merged 1 commit into from
Sep 20, 2024
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
16 changes: 16 additions & 0 deletions components/query_filter/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ static const auto kScopedQueryStringTrackers =
{"si", {"youtube.com", "youtu.be"}},
});

// URLs with these hostnames will not be modified by the query filter.
// These are exact match comparisons. Sub-domains are not
// automatically included.
static constexpr auto kExemptedHostnames =
base::MakeFixedFlatSet<std::string_view>(
base::sorted_unique,
{
// https://github.com/brave/brave-browser/issues/41134
"urldefense.com",
});

bool IsScopedTracker(
const std::string_view param_name,
const std::string& spec,
Expand Down Expand Up @@ -245,6 +256,11 @@ std::optional<GURL> MaybeApplyQueryStringFilter(
return std::nullopt;
}

if (request_url.has_host() &&
kExemptedHostnames.count(request_url.host()) == 1) {
return std::nullopt;
}

if (redirect_source_url.is_valid()) {
if (internal_redirect) {
// Ignore internal redirects since we trigger them.
Expand Down
8 changes: 8 additions & 0 deletions components/query_filter/utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ TEST(BraveQueryFilter, FilterQueryTrackers) {
EXPECT_FALSE(query_filter::MaybeApplyQueryStringFilter(
GURL("https://brave.com"), GURL("https://brave.com"),
GURL("https://test.com/?gclid=123"), "GET", true));
// Don't filter exempted hostnames
EXPECT_FALSE(query_filter::MaybeApplyQueryStringFilter(
GURL("https://brave.com"), GURL(),
GURL("https://urldefense.com/v3/__https://www.portainer.io/hs/"
"preferences-center/en/"
"direct?utm_campaign=XNF&utm_source=hs_automation&_hsenc=p2&_hsmi="
"26__;!!MlclJBHn!0eDf-z$"),
"GET", false));
}

TEST(BraveQueryFilter, IsScopedTracker) {
Expand Down
Loading