From bff113760a993d6b8b570e4b2e23173ffdec7538 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Fri, 1 Nov 2019 06:38:56 +0100 Subject: [PATCH] fix: use Unicode version of ShellExecute() in OpenExternalOnWorkerThread() (#20879) --- shell/common/platform_util_win.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shell/common/platform_util_win.cc b/shell/common/platform_util_win.cc index 8f5a9dd33052..b82b3bca747d 100644 --- a/shell/common/platform_util_win.cc +++ b/shell/common/platform_util_win.cc @@ -238,14 +238,11 @@ std::string OpenExternalOnWorkerThread( // Quote the input scheme to be sure that the command does not have // parameters unexpected by the external program. This url should already // have been escaped. - std::string escaped_url = url.spec(); - escaped_url.insert(0, "\""); - escaped_url += "\""; - - std::string working_dir = options.working_dir.AsUTF8Unsafe(); + base::string16 escaped_url = L"\"" + base::UTF8ToUTF16(url.spec()) + L"\""; + base::string16 working_dir = options.working_dir.value(); if (reinterpret_cast( - 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(), SW_SHOWNORMAL)) <= 32) { return "Failed to open";