From 67d86bc53df7595080eab0dfdb7072d4366ed559 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 7 Sep 2023 16:04:10 +0300 Subject: [PATCH] fix css_url_regex --- files/helpers/regex.py | 3 +-- files/helpers/sanitize.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 63ed0ab94..1de87407c 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -128,8 +128,7 @@ twitch_regex = re.compile('(https:\/\/)?(www\.)?twitch.tv\/(.*)', flags=re.I|re. link_fix_regex = re.compile("(\[.*?\]\()(?!http|\/)(.*?\))" + NOT_IN_CODE_OR_LINKS, flags=re.A) -css_url_regex = re.compile('url\(\s*[\'"]?([^\'"]*)', flags=re.I|re.A) -css_url2_regex = re.compile('(http[^\s]*)', flags=re.I|re.A) +css_url_regex = re.compile('url\(((.|\n)*?)\)', flags=re.I|re.A) linefeeds_regex = re.compile("([^\n])\n([^\n])", flags=re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 4d71adaef..fd55efb36 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -804,8 +804,7 @@ def validate_css(css): if '/*' in css: return False, "CSS comments are not allowed!" - matches = list(css_url_regex.finditer(css)) + list(css_url2_regex.finditer(css)) - for i in matches: + for i in css_url_regex.finditer(css): url = i.group(1) if not is_safe_url(url): domain = tldextract.extract(url).registered_domain