Skip to content

Commit 4fb862e

Browse files
dmcppcheckclaude
andcommitted
Do not quote addon executable, executeCommand already quotes it on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c2e89c9 commit 4fb862e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎lib/cppcheck.cpp‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ namespace {
326326
};
327327
}
328328

329-
std::string CppCheck::cmdFileName(std::string f)
329+
/** throw if filename contains characters that potentially has a special meaning for the shell */
330+
static void checkCmdFileName(const std::string& f)
330331
{
331-
// do not allow characters that potentially has a special meaning for the shell
332332
const auto badpos = f.find_first_of("\t\n\r;$<>|&`");
333333
if (badpos != std::string::npos) {
334334
std::string c;
@@ -342,6 +342,11 @@ std::string CppCheck::cmdFileName(std::string f)
342342
c += f[badpos];
343343
throw std::runtime_error("Cppcheck does not allow character " + c + " in filename " + f);
344344
}
345+
}
346+
347+
std::string CppCheck::cmdFileName(std::string f)
348+
{
349+
checkCmdFileName(f);
345350
f = Path::toNativeSeparators(std::move(f));
346351
if (f.find(' ') != std::string::npos)
347352
return "\"" + f + "\"";
@@ -477,9 +482,11 @@ static std::vector<picojson::value> executeAddon(const AddonInfo &addonInfo,
477482

478483
std::string pythonExe;
479484

480-
if (!addonInfo.executable.empty())
481-
pythonExe = CppCheck::cmdFileName(addonInfo.executable);
482-
else if (!addonInfo.python.empty())
485+
if (!addonInfo.executable.empty()) {
486+
// no quoting here, executeCommand quotes the executable if needed
487+
checkCmdFileName(addonInfo.executable);
488+
pythonExe = addonInfo.executable;
489+
} else if (!addonInfo.python.empty())
483490
pythonExe = CppCheck::cmdFileName(addonInfo.python);
484491
else if (!defaultPythonExe.empty())
485492
pythonExe = CppCheck::cmdFileName(defaultPythonExe);

0 commit comments

Comments
 (0)