Skip to content

Commit b1f03d4

Browse files
committedNov 30, 2022
ensure URLs are valid
1 parent f933b42 commit b1f03d4

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed
 

‎browser/net/brave_ad_block_tp_network_delegate_helper.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ EngineFlags ShouldBlockRequestOnTaskRunner(
207207
&previous_result.did_match_important, &ctx->mock_data_url,
208208
&rewritten_url);
209209

210-
if (ctx->method == "GET" || ctx->method == "HEAD" ||
211-
ctx->method == "OPTIONS") {
210+
if (GURL(rewritten_url).is_valid() &&
211+
(ctx->method == "GET" || ctx->method == "HEAD" ||
212+
ctx->method == "OPTIONS")) {
212213
ctx->new_url_spec = rewritten_url;
213214
}
214215

‎components/brave_shields/browser/domain_block_navigation_throttle.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ DomainBlockNavigationThrottle::WillProcessResponse() {
162162
void DomainBlockNavigationThrottle::OnShouldBlockDomain(
163163
std::pair<bool, std::string> block_result) {
164164
const bool should_block = block_result.first;
165-
const std::string new_url_spec = block_result.second;
166-
if (!should_block && new_url_spec.empty()) {
165+
const GURL new_url(block_result.second);
166+
if (!should_block && !new_url.is_valid()) {
167167
DomainBlockTabStorage* tab_storage = DomainBlockTabStorage::FromWebContents(
168168
navigation_handle()->GetWebContents());
169169
if (tab_storage)
@@ -172,7 +172,7 @@ void DomainBlockNavigationThrottle::OnShouldBlockDomain(
172172
// runner, but now we know that we want to allow navigation to continue.
173173
Resume();
174174
return;
175-
} else if (!new_url_spec.empty()) {
175+
} else if (new_url.is_valid()) {
176176
content::NavigationHandle* handle = navigation_handle();
177177

178178
content::WebContents* contents = handle->GetWebContents();
@@ -182,8 +182,6 @@ void DomainBlockNavigationThrottle::OnShouldBlockDomain(
182182
CancelDeferredNavigation(content::NavigationThrottle::ThrottleCheckResult(
183183
content::NavigationThrottle::CANCEL));
184184

185-
const GURL new_url(new_url_spec);
186-
187185
content::OpenURLParams params =
188186
content::OpenURLParams::FromNavigationHandle(handle);
189187
params.url = new_url;

0 commit comments

Comments
 (0)
Please sign in to comment.