diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 214d67948e8c3..ab88d666bf59d 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -2937,6 +2937,33 @@ void RenderWidgetHostImpl::StartDragging( } } + // Propagate the FilterURL results back into `drag_data` so that the DevTools + // intercept path (Input.dragIntercepted) sees the same filtered values as the + // OS-drag path. Without this, a CDP client following the documented + // dragIntercepted -> dispatchDragEvent round-trip would replay the + // pre-filter renderer-supplied URLs into DragTargetDrop. + for (auto& item : drag_data->items) { + if (!item->is_string()) { + continue; + } + auto& s = item->get_string(); + if (s->string_type == ui::kMimeTypeUriList) { + std::u16string rebuilt; + for (const auto& url_info : filtered_data.url_infos) { + if (!rebuilt.empty()) { + rebuilt.append(u"\r\n"); + } + rebuilt.append(base::UTF8ToUTF16(url_info.url.spec())); + } + s->string_data = std::move(rebuilt); + } else if (s->string_type == ui::kMimeTypeHtml) { + s->base_url = filtered_data.html_base_url; + } else if (s->string_type == ui::kMimeTypeDownloadUrl && + !filtered_data.download_metadata) { + s->string_data.clear(); + } + } + // Filter out any paths that the renderer didn't have access to. This prevents // the following attack on a malicious renderer: // 1. StartDragging IPC sent with renderer-specified filesystem paths that it