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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2811533002: Exclude files from FileSelectChooser if they can't convert to WebStrings. (Closed)
Patch Set: Move fix to RFH, add test. Created 3 years, 8 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
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 5fba3c3c600b524ebe622722c778279b67b3e85b..26dd92de50625d992f2f2e0c8fff4acab29688cb 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -3217,8 +3217,18 @@ void RenderFrameHostImpl::FilesSelectedInChooser(
BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(),
GetSiteInstance())
->GetFileSystemContext();
- // Grant the security access requested to the given files.
+
+ // Exclude files whose paths can't be converted into WebStrings, which we can
+ // approximate with AsUTF8Unsafe. Blink won't be able to handle these, and we
+ // would kill the renderer when it claims to have chosen an empty file path.
+ std::vector<content::FileChooserFileInfo> filtered_files;
for (const auto& file : files) {
+ if (!file.file_path.AsUTF8Unsafe().empty())
+ filtered_files.push_back(file);
+ }
+
+ // Grant the security access requested to the given files.
+ for (const auto& file : filtered_files) {
if (permissions == FileChooserParams::Save) {
ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile(
GetProcess()->GetID(), file.file_path);
@@ -3234,7 +3244,7 @@ void RenderFrameHostImpl::FilesSelectedInChooser(
}
}
- Send(new FrameMsg_RunFileChooserResponse(routing_id_, files));
+ Send(new FrameMsg_RunFileChooserResponse(routing_id_, filtered_files));
}
bool RenderFrameHostImpl::HasSelection() {

Powered by Google App Engine
This is Rietveld 408576698