electron/shell/common/command_line_util_win.h
Shelley Vohr f7507447ad
fix: use proper quoting for exe paths and args on Windows (#50016)
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.
2026-03-04 11:59:49 -05:00

20 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_