update pattern fix issue multi-line in text can be bypass

This commit is contained in:
noobpk 2021-11-19 15:24:40 +07:00
parent c54b89f143
commit 4a2ca815fd

View File

@ -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(