Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: components/dom_distiller/content/dom_distiller_viewer_source.cc

Issue 288353002: [dom_distiller] Fix crash for invalid chrome-distiller:// requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added expect_distiller_page_ Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/content/dom_distiller_viewer_source.cc
diff --git a/components/dom_distiller/content/dom_distiller_viewer_source.cc b/components/dom_distiller/content/dom_distiller_viewer_source.cc
index 22ceab6d9f239992c3d837b3a5be8642e0f685d7..26c650266d3d6f5e0bde7c13e774c7cef8c9cf95 100644
--- a/components/dom_distiller/content/dom_distiller_viewer_source.cc
+++ b/components/dom_distiller/content/dom_distiller_viewer_source.cc
@@ -273,8 +273,12 @@ void DomDistillerViewerSource::StartDataRequest(
content::RenderFrameHost::FromID(render_process_id,
render_frame_id));
DCHECK(web_contents);
- RequestViewerHandle* request_viewer_handle =
- new RequestViewerHandle(web_contents, scheme_, path.substr(1), callback);
+ // An empty |path| is invalid, but guard against it. If not empty, assume
+ // |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(
dom_distiller_service_, path, request_viewer_handle);
« no previous file with comments | « chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698