Simplify and fix handling of incomplete substitution strings
This commit is contained in:
@@ -711,13 +711,15 @@ namespace platf {
|
|||||||
while ((match_pos = cmd_string.find_first_of(L'%', match_pos)) != std::wstring::npos) {
|
while ((match_pos = cmd_string.find_first_of(L'%', match_pos)) != std::wstring::npos) {
|
||||||
std::wstring match_replacement;
|
std::wstring match_replacement;
|
||||||
|
|
||||||
// Shell command replacements are strictly '%' followed by a single non-'%' character
|
// If no additional character exists after the match, the dangling '%' is stripped
|
||||||
auto next_char = std::tolower(match_pos + 1 < cmd_string.size() ? cmd_string.at(match_pos + 1) : 0);
|
if (match_pos + 1 == cmd_string.size()) {
|
||||||
switch (next_char) {
|
cmd_string.erase(match_pos, 1);
|
||||||
// No next character
|
|
||||||
case 0:
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shell command replacements are strictly '%' followed by a single non-'%' character
|
||||||
|
auto next_char = std::tolower(cmd_string.at(match_pos + 1));
|
||||||
|
switch (next_char) {
|
||||||
// Escape character
|
// Escape character
|
||||||
case L'%':
|
case L'%':
|
||||||
// Skip this character and the next one
|
// Skip this character and the next one
|
||||||
|
|||||||
Reference in New Issue
Block a user