From 4a2ca815fd1788b6e4852d8324035b88f9276454 Mon Sep 17 00:00:00 2001 From: noobpk Date: Fri, 19 Nov 2021 15:24:40 +0700 Subject: [PATCH] update pattern fix issue multi-line in text can be bypass --- helpdesk/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index a2d7f901..d2dcaae2 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -57,8 +57,8 @@ def get_markdown(text): return "" schemes = '|'.join(helpdesk_settings.ALLOWED_URL_SCHEMES) - pattern = fr'\[(.+)\]\((?!({schemes})).*:(.+)\)' - text = re.sub(pattern, '[\\1](\\3)', text, flags=re.IGNORECASE) + pattern = fr'([\[\s\S\]]*?)\((?!({schemes})).*:(.+)\)' + text = re.sub(pattern, '\\1(\\3)', text, flags=re.IGNORECASE) return mark_safe( markdown(