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); |