From 24d3a5a48da5c99c83f9933937be9f3c5008d85a Mon Sep 17 00:00:00 2001 From: CapnS Date: Fri, 29 Mar 2019 10:57:49 -0500 Subject: [PATCH] Only escape characters as necessary in clean_content Fixes #1885 --- discord/ext/commands/converter.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 98d601fdc..600f4be92 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -473,16 +473,11 @@ class clean_content(Converter): result = pattern.sub(repl, argument) if self.escape_markdown: - transformations = { - re.escape(c): '\\' + c - for c in ('*', '`', '_', '~', '\\', '||') - } - - def replace(obj): - return transformations.get(re.escape(obj.group(0)), '') - - pattern = re.compile('|'.join(transformations.keys())) - result = pattern.sub(replace, result) + result = re.sub(r'\\', r'\\\\', result) + for c in ('*', '`', '_', '~', '|'): + regex = r'\{0}(?=([\s\S]*((?