CommonClient: Escape markup sent in chat messages (#3659)

* escape markup in uncolored text

* Fix comment to allign with style guide

Fixes the comment so it follows the style guide, along with making it
better explain the code.

* Make more concise
This commit is contained in:
gurglemurgle5 2024-07-19 01:37:59 -05:00 committed by GitHub
parent 4d1507cd0e
commit e33a9991ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -836,6 +836,10 @@ class KivyJSONtoTextParser(JSONtoTextParser):
return self._handle_text(node) return self._handle_text(node)
def _handle_text(self, node: JSONMessagePart): def _handle_text(self, node: JSONMessagePart):
# All other text goes through _handle_color, and we don't want to escape markup twice,
# or mess up text that already has intentional markup applied to it
if node.get("type", "text") == "text":
node["text"] = escape_markup(node["text"])
for ref in node.get("refs", []): for ref in node.get("refs", []):
node["text"] = f"[ref={self.ref_count}|{ref}]{node['text']}[/ref]" node["text"] = f"[ref={self.ref_count}|{ref}]{node['text']}[/ref]"
self.ref_count += 1 self.ref_count += 1