Skip to content

Commit

Permalink
CommonClient: Escape markup sent in chat messages (ArchipelagoMW#3659)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gurglemurgle5 authored Jul 19, 2024
1 parent 4d1507c commit e33a999
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kvui.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,10 @@ def _handle_color(self, node: JSONMessagePart):
return self._handle_text(node)

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", []):
node["text"] = f"[ref={self.ref_count}|{ref}]{node['text']}[/ref]"
self.ref_count += 1
Expand Down

0 comments on commit e33a999

Please sign in to comment.