fix: use Unicode version of ShellExecute() in OpenExternalOnWorkerThread() (#20879)

This commit is contained in:
Milan Burda 2019-11-01 06:38:56 +01:00 committed by Cheng Zhao
parent 7ae8538847
commit bff113760a

View file

@ -238,14 +238,11 @@ std::string OpenExternalOnWorkerThread(
// Quote the input scheme to be sure that the command does not have // Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already // parameters unexpected by the external program. This url should already
// have been escaped. // have been escaped.
std::string escaped_url = url.spec(); base::string16 escaped_url = L"\"" + base::UTF8ToUTF16(url.spec()) + L"\"";
escaped_url.insert(0, "\""); base::string16 working_dir = options.working_dir.value();
escaped_url += "\"";
std::string working_dir = options.working_dir.AsUTF8Unsafe();
if (reinterpret_cast<ULONG_PTR>( if (reinterpret_cast<ULONG_PTR>(
ShellExecuteA(nullptr, "open", escaped_url.c_str(), nullptr, ShellExecuteW(nullptr, L"open", escaped_url.c_str(), nullptr,
working_dir.empty() ? nullptr : working_dir.c_str(), working_dir.empty() ? nullptr : working_dir.c_str(),
SW_SHOWNORMAL)) <= 32) { SW_SHOWNORMAL)) <= 32) {
return "Failed to open"; return "Failed to open";