Sanitize log_matches input
Given that the pattern is given as an argument quoted with single quotes, embedded single quotes are a problem. Given that most cases that they are used for is as parts of natural words like can't or won't. By replacing the single quotes with wildcard characters, we make sure the input is formatted correctly while still matching with relatively high accuracy.
This commit is contained in:
parent
4b6aab1417
commit
355f34669d
@ -1233,7 +1233,18 @@ int TestConnections::start_mm(int m)
|
||||
|
||||
bool TestConnections::log_matches(int m, const char* pattern)
|
||||
{
|
||||
return maxscales->ssh_node_f(m, true, "grep '%s' /var/log/maxscale/maxscale*.log", pattern) == 0;
|
||||
|
||||
// Replace single quotes with wildcard characters, should solve most problems
|
||||
std::string p = pattern;
|
||||
for (auto& a : p)
|
||||
{
|
||||
if (a == '\'')
|
||||
{
|
||||
a = '.';
|
||||
}
|
||||
}
|
||||
|
||||
return maxscales->ssh_node_f(m, true, "grep '%s' /var/log/maxscale/maxscale*.log", p.c_str()) == 0;
|
||||
}
|
||||
|
||||
void TestConnections::log_includes(int m, const char* pattern)
|
||||
|
Loading…
x
Reference in New Issue
Block a user