master
Aevann1 2022-04-18 01:00:17 +02:00
parent c7d3401b62
commit 69d285b0f3
3 changed files with 5 additions and 5 deletions

View File

@ -478,7 +478,7 @@ class Submission(Base):
@property @property
@lazy @lazy
def is_image(self): def is_image(self):
if self.url and (self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('&fidelity=high')) and embed_check_regex.fullmatch(self.url): if self.url and (self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('&fidelity=high')) and (self.url.startswith('/') or self.url.startswith(f'{SITE_FULL}/') or embed_check_regex.fullmatch(self.url)):
return True return True
return False return False

View File

@ -810,8 +810,8 @@ approved_embed_hosts = [
hosts = "|".join(approved_embed_hosts).replace('.','\.') hosts = "|".join(approved_embed_hosts).replace('.','\.')
image_check_regex = re.compile(f'!\[\]\(((?!(https:\/\/([a-z0-9-]+\.)*({hosts}))?\/).*?)\)', flags=re.A) image_check_regex = re.compile(f'!\[\]\(((?!(https:\/\/([a-z0-9-]+\.)*({hosts})\/|\/images\/)).*?)\)', flags=re.A)
embed_check_regex = regex.compile(f'(?<!<(code|pre|a)>)(https:\/\/([a-z0-9-]+\.)*({hosts}))?\/[\w:~,()\-.#&\/=?@%;+]*', flags=regex.A) embed_check_regex = regex.compile(f'(?<!<(code|pre|a)>)https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*', flags=regex.A)
video_regex = regex.compile(f'((?<!<(code|pre|a)>)(https:\/\/([a-z0-9-]+\.)*({hosts}))?\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=regex.A) video_regex = regex.compile(f'((?<!<(code|pre|a)>)https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=regex.A)

View File

@ -37,7 +37,7 @@ def allowed_attributes(tag, name, value):
if tag == 'img': if tag == 'img':
if name in ['src','data-src']: if name in ['src','data-src']:
if embed_check_regex.fullmatch(value): return True if value.startswith('/') or value.startswith(f'{SITE_FULL}/') or embed_check_regex.fullmatch(value): return True
else: return False else: return False
if name == 'loading' and value == 'lazy': return True if name == 'loading' and value == 'lazy': return True