This commit is contained in:
Aevann1 2021-10-23 16:35:35 +02:00
parent 495112c7c6
commit ff0abf6fd8
8 changed files with 26 additions and 24 deletions

View file

@ -101,15 +101,14 @@ def settings_profile_post(v):
updated = True
v.is_nofollow = request.values.get("nofollow", None) == 'true'
if request.values.get("bio") or request.files.get('file'):
if request.values.get("bio") or request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
bio = request.values.get("bio")[:1500]
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE):
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})')
bio = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', bio)
if request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
if request.files.get('file'):
file = request.files['file']
if not file.content_type.startswith('image/'):
if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400
@ -120,7 +119,7 @@ def settings_profile_post(v):
url = request.host_url[:-1] + process_image(name)
bio += f"\n\n![]({url})"
bio_html = CustomRenderer().render(mistletoe.Document(bio))
bio_html = sanitize(bio_html)
bans = filter_comment_html(bio_html)