mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-12 17:36:42 +00:00
escape more characters when sanitizing for markdown (#1681)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
fc8b81ecc4
commit
4611628554
@ -33,8 +33,11 @@ class JinjaHelpers:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def sanitize_for_md(cls, value: str) -> str:
|
def sanitize_for_md(cls, value: str) -> str:
|
||||||
"""Sanitizes given value for markdown."""
|
"""Sanitizes given value for markdown."""
|
||||||
sanitized_value = re.sub(r"([|])", r"\\\1", value)
|
# modified from https://github.com/python-telegram-bot/python-telegram-bot/blob/1fdaaac8094c9d76c34c8c8e8c9add16080e75e7/telegram/utils/helpers.py#L149
|
||||||
return sanitized_value
|
escape_chars = r"_*[]()~`>#+-=|{}!"
|
||||||
|
escaped_value = re.sub(f"([{re.escape(escape_chars)}])", r"\\\1", value)
|
||||||
|
escaped_value = escaped_value.replace("\n", "").replace("\r", "")
|
||||||
|
return escaped_value
|
||||||
|
|
||||||
|
|
||||||
class JinjaService:
|
class JinjaService:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user