Merge pull request #191 from Robinhuett/escape_userinput

fix: Escape user controlled input
This commit is contained in:
Alex 2019-02-25 18:46:17 +01:00 committed by GitHub
commit 961a05bedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,7 @@ void waybar::modules::Custom::parseOutputRaw()
int i = 0; int i = 0;
while (getline(output, line)) { while (getline(output, line)) {
if (i == 0) { if (i == 0) {
text_ = line; text_ = Glib::Markup::escape_text(line);
tooltip_ = line; tooltip_ = line;
class_ = ""; class_ = "";
} else if (i == 1) { } else if (i == 1) {
@ -143,7 +143,7 @@ void waybar::modules::Custom::parseOutputJson()
std::string line; std::string line;
while (getline(output, line)) { while (getline(output, line)) {
auto parsed = parser_.parse(line); auto parsed = parser_.parse(line);
text_ = parsed["text"].asString(); text_ = Glib::Markup::escape_text(parsed["text"].asString());
tooltip_ = parsed["tooltip"].asString(); tooltip_ = parsed["tooltip"].asString();
class_ = parsed["class"].asString(); class_ = parsed["class"].asString();
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) { if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) {

View File

@ -20,7 +20,7 @@ void waybar::modules::sway::Mode::worker()
auto res = ipc_.handleEvent(); auto res = ipc_.handleEvent();
auto parsed = parser_.parse(res.payload); auto parsed = parser_.parse(res.payload);
if (parsed["change"] != "default") { if (parsed["change"] != "default") {
mode_ = parsed["change"].asString(); mode_ = Glib::Markup::escape_text(parsed["change"].asString());
} else { } else {
mode_.clear(); mode_.clear();
} }