Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wide string concatenation #40909

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion patches/chromium/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,4 @@ revert_same_party_cookie_attribute_removal.patch
fix_restore_original_resize_performance_on_macos.patch
fix_font_flooding_in_dev_tools.patch
feat_allow_code_cache_in_custom_schemes.patch
cherry-pick-8d607d3921b8.patch
enable_partition_alloc_ref_count_size.patch
33 changes: 0 additions & 33 deletions patches/chromium/cherry-pick-8d607d3921b8.patch

This file was deleted.

19 changes: 9 additions & 10 deletions shell/browser/browser_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/strcat_win.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "base/win/win_util.h"
Expand Down Expand Up @@ -68,13 +68,13 @@ bool GetProtocolLaunchPath(gin::Arguments* args, std::wstring* exe) {

// Read in optional args arg
std::vector<std::wstring> launch_args;
if (args->GetNext(&launch_args) && !launch_args.empty())
*exe = base::UTF8ToWide(
base::StringPrintf("\"%ls\" \"%ls\" \"%%1\"", exe->c_str(),
base::JoinString(launch_args, L"\" \"").c_str()));
else
*exe =
base::UTF8ToWide(base::StringPrintf("\"%ls\" \"%%1\"", exe->c_str()));
if (args->GetNext(&launch_args) && !launch_args.empty()) {
std::wstring joined_args = base::JoinString(launch_args, L"\" \"");
*exe = base::StrCat({L"\"", *exe, L"\" \"", joined_args, L"\" \"%1\""});
} else {
*exe = base::StrCat({L"\"", *exe, L"\" \"%1\""});
}

return true;
}

Expand Down Expand Up @@ -142,8 +142,7 @@ bool FormatCommandLineString(std::wstring* exe,

if (!launch_args.empty()) {
std::u16string joined_launch_args = base::JoinString(launch_args, u" ");
*exe = base::UTF8ToWide(base::StringPrintf(
"%ls %ls", exe->c_str(), base::as_wcstr(joined_launch_args)));
*exe = base::StrCat({*exe, L" ", base::AsWStringPiece(joined_launch_args)});
}

return true;
Expand Down
7 changes: 4 additions & 3 deletions shell/browser/relauncher_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#include "base/logging.h"
#include "base/process/launch.h"
#include "base/strings/stringprintf.h"
#include "base/strings/strcat_win.h"
#include "base/strings/string_number_conversions_win.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
#include "sandbox/win/src/nt_internals.h"
Expand Down Expand Up @@ -109,8 +110,8 @@ StringType AddQuoteForArg(const StringType& arg) {
} // namespace

StringType GetWaitEventName(base::ProcessId pid) {
return base::UTF8ToWide(
base::StringPrintf("%ls-%d", kWaitEventName, static_cast<int>(pid)));
return base::StrCat(
{kWaitEventName, L"-", base::NumberToWString(static_cast<int>(pid))});
}

StringType ArgvToCommandLineString(const StringVector& argv) {
Expand Down