escape percent signs so wprintw won't replace them with random things

This commit is contained in:
eater 2020-03-05 15:07:38 +01:00
parent 6d61ff8333
commit 27cb6cf45d
No known key found for this signature in database
GPG Key ID: AD2560A0F84F0759

View File

@ -304,6 +304,14 @@ static size_t writePlayingFormat(
}
}
/* any % in the value string might be parsed by wprintw, so replace it */
std::size_t percentSignIndex = value.find("%");
while (percentSignIndex != std::string::npos) {
value.replace(percentSignIndex, 1, "%%");
/* we replaced one % with 2 of them, so we need to skip ahead 2 chars */
percentSignIndex = value.find("%", percentSignIndex + 2);
}
ON(w, attr);
checked_wprintw(w, value.c_str());
OFF(w, attr);
@ -732,4 +740,4 @@ void TransportWindow::Update(TimeMode timeMode) {
OFF(c, repeatAttrs);
this->Invalidate();
}
}