Commit 04d24fc9 authored by Nicolò Mazzucato's avatar Nicolò Mazzucato Committed by Commit Bot

devtools: Prevent crash when inspecting devtools:// page

Only in a debug build we can enter in the branch
"content::hasWebUIScheme" (:758) if the scheme is either "chrome://" or
"devtools://". Later, constructing the WebURILoader (in :772 before the
patch), there is the assumption that the uri scheme is always
kChromeUIScheme. This was causing me  crash of devtools while I was
trying to open it on a page under "devtools://devtools/...".
The crash was generated by web_ui_url_loader_factory.cc:254, where
`scheme_` was "chrome", while `request.url.scheme()` was "devtools"

Change-Id: If02ea147d494ed64c7f7dc560095f223c11f7dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1687408
Commit-Queue: Nicolò Mazzucato <nicomazz@google.com>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676911}
parent abcfa634
...@@ -756,11 +756,12 @@ void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback, ...@@ -756,11 +756,12 @@ void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback,
nullptr /* shared_cors_origin_access_list */); nullptr /* shared_cors_origin_access_list */);
url_loader_factory = file_url_loader_factory.get(); url_loader_factory = file_url_loader_factory.get();
} else if (content::HasWebUIScheme(gurl)) { } else if (content::HasWebUIScheme(gurl)) {
content::WebContents* target_tab;
#ifndef NDEBUG #ifndef NDEBUG
// In debug builds, allow retrieving files from the chrome:// scheme // In debug builds, allow retrieving files from the chrome:// and
content::WebContents* target_tab = // devtools:// schemes
DevToolsWindow::AsDevToolsWindow(web_contents_) target_tab = DevToolsWindow::AsDevToolsWindow(web_contents_)
->GetInspectedWebContents(); ->GetInspectedWebContents();
const bool allow_web_ui_scheme = const bool allow_web_ui_scheme =
target_tab && content::HasWebUIScheme(target_tab->GetURL()); target_tab && content::HasWebUIScheme(target_tab->GetURL());
#else #else
...@@ -770,7 +771,8 @@ void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback, ...@@ -770,7 +771,8 @@ void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback,
std::vector<std::string> allowed_webui_hosts; std::vector<std::string> allowed_webui_hosts;
content::RenderFrameHost* frame_host = web_contents()->GetMainFrame(); content::RenderFrameHost* frame_host = web_contents()->GetMainFrame();
webui_url_loader_factory = content::CreateWebUIURLLoader( webui_url_loader_factory = content::CreateWebUIURLLoader(
frame_host, content::kChromeUIScheme, std::move(allowed_webui_hosts)); frame_host, target_tab->GetURL().scheme(),
std::move(allowed_webui_hosts));
url_loader_factory = webui_url_loader_factory.get(); url_loader_factory = webui_url_loader_factory.get();
} else { } else {
base::DictionaryValue response; base::DictionaryValue response;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment