Commit 1cbaeba0 authored by nyquist@chromium.org's avatar nyquist@chromium.org

[dom_distiller] Fix crash for invalid chrome-distiller:// requests

When the DomDistillerViewerSource got a request for chrome-distiller://foobar/
it would crash if there was an empty path argument. This CL adds a safety check
for the length of the path, to ensure to not take a substring of an empty
string. 

In addition, this adds regression tests for the crash it fixes. It also fixes
the rest of the disabled browser tests for the DomDistillerViewerSource. 

BUG=356866

Review URL: https://codereview.chromium.org/288353002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271178 0039d316-1c4b-4281-b951-d872f2087c98
parent d7852f91
...@@ -273,8 +273,12 @@ void DomDistillerViewerSource::StartDataRequest( ...@@ -273,8 +273,12 @@ void DomDistillerViewerSource::StartDataRequest(
content::RenderFrameHost::FromID(render_process_id, content::RenderFrameHost::FromID(render_process_id,
render_frame_id)); render_frame_id));
DCHECK(web_contents); DCHECK(web_contents);
RequestViewerHandle* request_viewer_handle = // An empty |path| is invalid, but guard against it. If not empty, assume
new RequestViewerHandle(web_contents, scheme_, path.substr(1), callback); // |path| starts with '?', which is stripped away.
const std::string path_after_query_separator =
path.size() > 0 ? path.substr(1) : "";
RequestViewerHandle* request_viewer_handle = new RequestViewerHandle(
web_contents, scheme_, path_after_query_separator, callback);
scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest( scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest(
dom_distiller_service_, path, request_viewer_handle); dom_distiller_service_, path, request_viewer_handle);
......
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