Skip to content

Commit e81fb4f

Browse files
Copilotseven7ty
andauthored
chore: harden tilde fences and clean error sanitization formatting
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/46b730a3-a822-49cd-9473-c994c6dd7db6 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
1 parent 3d68eff commit e81fb4f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

cogs/backend/handle/errors/_error_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ async def log_error_in_discord(ctx: GitBotContext, error: Exception, _actual=Non
4242
)
4343
message: str = ctx.bot.mgr.sanitize_codeblock_content(str(error))
4444
tb: str = ctx.bot.mgr.sanitize_codeblock_content(format_tb(error.__traceback__))
45+
sanitized_args: str = ctx.bot.mgr.sanitize_codeblock_content(format_args(ctx.args))
46+
sanitized_kwargs: str = ctx.bot.mgr.sanitize_codeblock_content(format_kwargs(ctx.kwargs))
4547
embed.add_field(name='Message', value=f'```{message}```')
4648
embed.add_field(name='Traceback', value=f'```{tb}```')
4749
embed.add_field(name='Arguments',
48-
value=f'```properties\nargs={ctx.bot.mgr.sanitize_codeblock_content(format_args(ctx.args))}\nkwargs={ctx.bot.mgr.sanitize_codeblock_content(format_kwargs(ctx.kwargs))}```')
50+
value=f'```properties\nargs={sanitized_args}\nkwargs={sanitized_kwargs}```')
4951
elif isinstance(error, commands.CommandNotFound):
5052
error_text: str = ctx.bot.mgr.sanitize_codeblock_content(str(error))
5153
embed: GitBotEmbed = GitBotEmbed(

lib/manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def sanitize_codeblock_content(content: str | None, neutralize_mentions: bool =
243243
if not content:
244244
return ''
245245
content = content.replace('```', '`\u200b`\u200b`')
246+
content = content.replace('~~~', '~\u200b~\u200b~')
246247
if neutralize_mentions:
247248
content = content.replace('@', '@\u200b')
248249
return content

0 commit comments

Comments
 (0)