diff --git a/files/helpers/regex.py b/files/helpers/regex.py index ff94f92ca..45e949e73 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -76,7 +76,7 @@ yt_id_regex = re.compile('[a-z0-9-_]{5,20}', flags=re.I|re.A) image_regex = re.compile("(^|\s)(https:\/\/[\w\-.#&/=\?@%;+,:]{5,250}(\.png|\.jpg|\.jpeg|\.gif|\.webp)(\?[\w\-.#&/=\?@%;+,:]*)?)($|\s)", flags=re.I|re.A) -link_fix_regex = re.compile("(?!.*(http|\/))(.*\[[^\]]+\]\()([^)]+\))", flags=re.A) +link_fix_regex = re.compile("(\[.*?\]\()(?!http|/)(.*?\))", flags=re.A) css_regex = re.compile('https?:\/\/[\w:~,()\-.#&\/=?@%;+]*', flags=re.I|re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index a9cff03c0..f524897eb 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -182,7 +182,7 @@ def sanitize(sanitized, edit=False): sanitized = image_check_regex.sub(r'\1', sanitized) - sanitized = link_fix_regex.sub(r'\2https://\3', sanitized) + sanitized = link_fix_regex.sub(r'\1https://\2', sanitized) sanitized = markdown(sanitized)