mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-27 09:08:53 +01:00
Update pattern and code check
This commit is contained in:
parent
4a2ca815fd
commit
7097c9c4c0
@ -56,9 +56,18 @@ def get_markdown(text):
|
||||
if not text:
|
||||
return ""
|
||||
|
||||
schemes = '|'.join(helpdesk_settings.ALLOWED_URL_SCHEMES)
|
||||
pattern = fr'([\[\s\S\]]*?)\((?!({schemes})).*:(.+)\)'
|
||||
text = re.sub(pattern, '\\1(\\3)', text, flags=re.IGNORECASE)
|
||||
pattern = fr'([\[\s\S\]]*?)\(([\s\S]*?):([\[\s\S\]]*?)\)'
|
||||
# Regex check
|
||||
if re.match(pattern, text):
|
||||
# get get value of group regex
|
||||
scheme = re.search(pattern, text, re.IGNORECASE).group(2)
|
||||
# scheme check
|
||||
if scheme in helpdesk_settings.ALLOWED_URL_SCHEMES:
|
||||
replacement = '\\1(\\2:\\3)'
|
||||
else:
|
||||
replacement = '\\1(\\3)'
|
||||
|
||||
text = re.sub(pattern, replacement, text, flags=re.IGNORECASE)
|
||||
|
||||
return mark_safe(
|
||||
markdown(
|
||||
|
Loading…
Reference in New Issue
Block a user