Skip to content

Commit b630e45

Browse files
committed
fix escaping
1 parent 7c6ec17 commit b630e45

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
# v22.7.22
6+
57
### Bugfixes
68

79
* Interrupt long-running evaluations if time limit is reached
810
* Fix handling of protected programs
911
* Fix progress monitor for native mining (non-BOINC)
12+
* Fix escaping in Slack messages and metric labels
1013

1114
### Enhancements
1215

src/metrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void Metrics::write(const std::vector<Entry> entries) const {
4343
out << entry.field;
4444
for (auto &l : entry.labels) {
4545
auto v = l.second;
46-
std::replace(v.begin(), v.end(), ' ', '_');
46+
replaceAll(v, " ", "\\ ");
4747
out << "," << l.first << "=" << v;
4848
}
4949
out << " value=" << entry.value << "\n";

src/util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ void Log::alert(const std::string &msg, AlertDetails details) {
106106
void Log::slack(const std::string &msg, AlertDetails details) {
107107
std::string cmd;
108108
if (!details.text.empty()) {
109-
std::replace(details.text.begin(), details.text.end(), '"', ' ');
110-
std::replace(details.title.begin(), details.title.end(), '"', ' ');
109+
replaceAll(details.text, "\\", "\\\\"); // first escape backslashes
110+
replaceAll(details.text, "\"", "\\\""); // then the rest
111+
replaceAll(details.title, "\"", "\\\"");
111112
size_t index = 0;
112113
while (true) {
113114
index = details.text.find("$", index);

0 commit comments

Comments
 (0)