diff --git a/src/ui/elements/ui_element.cpp b/src/ui/elements/ui_element.cpp
index c60ee1c..6e67bfa 100644
--- a/src/ui/elements/ui_element.cpp
+++ b/src/ui/elements/ui_element.cpp
@@ -272,10 +272,30 @@ bool Element::is_enabled() const {
return enabled && !disabled_from_parent;
}
+// Adapted from RmlUi's `EncodeRml`.
+std::string escape_rml(std::string_view string)
+{
+ std::string result;
+ result.reserve(string.size());
+ for (char c : string)
+ {
+ switch (c)
+ {
+ case '<': result += "<"; break;
+ case '>': result += ">"; break;
+ case '&': result += "&"; break;
+ case '"': result += """; break;
+ case '\n': result += "
"; break;
+ default: result += c; break;
+ }
+ }
+ return result;
+}
+
void Element::set_text(std::string_view text) {
if (can_set_text) {
// Escape the string into Rml to prevent element injection.
- base->SetInnerRML(Rml::StringUtilities::EncodeRml(std::string(text)));
+ base->SetInnerRML(escape_rml(text));
}
else {
assert(false && "Attempted to set text of an element that cannot have its text set.");
diff --git a/src/ui/elements/ui_element.h b/src/ui/elements/ui_element.h
index 2dbd3bf..b4a8e97 100644
--- a/src/ui/elements/ui_element.h
+++ b/src/ui/elements/ui_element.h
@@ -61,7 +61,7 @@ public:
virtual ~Element();
void clear_children();
bool remove_child(ResourceId child);
- bool remove_child(Element *child) { remove_child(child->get_resource_id()); }
+ bool remove_child(Element *child) { return remove_child(child->get_resource_id()); }
void add_style(Style *style, std::string_view style_name);
void add_style(Style *style, const std::initializer_list &style_names);
void set_enabled(bool enabled);
diff --git a/src/ui/ui_mod_details_panel.cpp b/src/ui/ui_mod_details_panel.cpp
index 4903bf8..00fb557 100644
--- a/src/ui/ui_mod_details_panel.cpp
+++ b/src/ui/ui_mod_details_panel.cpp
@@ -83,7 +83,7 @@ void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, c
title_label->set_text(cur_details.display_name);
version_label->set_text(cur_details.version.to_string());
- std::string authors_str = "Authors:";
+ std::string authors_str = "Authors:";
bool first = true;
for (const std::string& author : details.authors) {
authors_str += (first ? " " : ", ") + author;