Skip to content

Commit d5bff84

Browse files
Copilotseven7ty
andauthored
chore: harden sanitizer null-safety for codeblock content
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/71de78f4-95f9-4b00-bbde-4a621af540f1 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
1 parent 02ef196 commit d5bff84

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,17 @@ def truncate(str_: str, length: int, ending: str = '...', full_word: bool = Fals
232232
return str_
233233

234234
@staticmethod
235-
def sanitize_codeblock_content(content: str, neutralize_mentions: bool = True) -> str:
235+
def sanitize_codeblock_content(content: str | None, neutralize_mentions: bool = True) -> str:
236236
"""
237237
Harden untrusted text for Discord fenced code blocks.
238238
239239
:param content: The text to sanitize
240240
:param neutralize_mentions: Whether to prevent mention abuse
241241
:return: The sanitized text
242242
"""
243-
content: str = content.replace('```', '`\u200b``')
243+
if not content:
244+
return ''
245+
content = content.replace('```', '`\u200b``')
244246
if neutralize_mentions:
245247
content = content.replace('@', '@\u200b')
246248
return content

0 commit comments

Comments
 (0)