13
0

Fix cmdline parameter escape

This commit is contained in:
Robin Gareus 2020-10-31 13:18:12 +01:00
parent 40ed19767a
commit 7896c30508
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 14 additions and 4 deletions

View File

@ -631,9 +631,16 @@ ARDOUR::get_jack_default_server_path (std::string& server_path)
return true;
}
string
quote_string (const string& str)
static string
quote_string (string str)
{
/* escape quotes in string */
size_t pos = 0;
while ((pos = str.find("\"", pos)) != std::string::npos) {
str.replace (pos, 1, "\\\"");
pos += 2;
}
/* and quote the whole string */
return "\"" + str + "\"";
}

View File

@ -215,8 +215,11 @@ SystemExec::SystemExec (std::string command, const std::map<char, std::string> s
// ...but always quote all args
for (int i = 1; argp[i]; ++i) {
std::string tmp (argp[i]);
while (tmp.find("\"") != std::string::npos)
tmp.replace(tmp.find("\""), 1, "\\\"");
size_t start_pos = 0;
while ((start_pos = tmp.find("\"", start_pos)) != std::string::npos) {
tmp.replace (start_pos, 1, "\\\"");
start_pos += 2;
}
wa += " \"";
wa += tmp;
wa += '"';