Files
electron/shell/common/command_line_util_win.h
trop[bot] 60951cdca9 fix: use proper quoting for exe paths and args on Windows (#50075)
Previously, GetProtocolLaunchPath and FormatCommandLineString in
browser_win.cc used naive quoting which could break when paths or
arguments contained backslashes, spaces, or embedded quotes.

Fix by extracting the CommandLineToArgvW-compatible quoting logic from
relauncher_win.cc into a shared utility and use it in both browser_win.cc
and relauncher_win.cc to properly quote the exe path and each argument
individually.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2026-03-05 10:27:40 +01:00

21 lines
713 B
C++

// Copyright (c) 2026 Microsoft GmbH.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_COMMAND_LINE_UTIL_WIN_H_
#define ELECTRON_SHELL_COMMON_COMMAND_LINE_UTIL_WIN_H_
#include <string>
namespace electron {
// Quotes |arg| using CommandLineToArgvW-compatible quoting rules so that
// the argument round-trips correctly through CreateProcess →
// CommandLineToArgvW. If no quoting is necessary the string is returned
// unchanged. See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
std::wstring AddQuoteForArg(const std::wstring& arg);
} // namespace electron
#endif // ELECTRON_SHELL_COMMON_COMMAND_LINE_UTIL_WIN_H_