mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-24 06:15:57 +01:00
Added escaping of {
, }
and $
This commit is contained in:
parent
6cbb4bf312
commit
c2ece0be06
2 changed files with 17 additions and 6 deletions
|
@ -158,17 +158,26 @@ std::string BarCommands::parseCommand(std::string command) {
|
|||
else if (c == '$') {
|
||||
// find the next one
|
||||
for (long unsigned int j = i + 1; i < command.length(); ++j) {
|
||||
if (command[j] == '$') {
|
||||
if (command[j] == '$' && command[j - 1] != '\\') {
|
||||
// found!
|
||||
auto toSend = command.substr(i + 1);
|
||||
toSend = toSend.substr(0, toSend.find_first_of('$'));
|
||||
result += parseDollar(toSend);
|
||||
auto toSend = command.substr(i + 1, j - (i + 1));
|
||||
std::string toSendWithRemovedEscapes = "";
|
||||
for (std::size_t k = 0; k < toSend.length(); ++k) {
|
||||
if (toSend[k] == '\\' && (k + 1) < toSend.length()) {
|
||||
char next = toSend[k + 1];
|
||||
if (next == '$' || next == '{' || next == '}') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
toSendWithRemovedEscapes += toSend[k];
|
||||
}
|
||||
result += parseDollar(toSendWithRemovedEscapes);
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if (j + 1 == command.length()) {
|
||||
Debug::log(ERR, "Unescaped $ in a module, module command: ");
|
||||
Debug::log(ERR, "Unpaired $ in a module, module command: ");
|
||||
Debug::log(NONE, command);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,9 @@ void parseLine(std::string& line) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (line.find("}") != std::string::npos && ConfigManager::currentCategory != "") {
|
||||
std::size_t closingBrace = line.find("}");
|
||||
if (closingBrace != std::string::npos && ConfigManager::currentCategory != "" &&
|
||||
(closingBrace == 0 || line[closingBrace - 1] != '\\')) {
|
||||
ConfigManager::currentCategory = "";
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue