remotes/1693045480750635534/spooky-22
Aevann1 2021-10-18 20:41:56 +02:00
parent 471cd9d322
commit aa6d9cd5cd
1 changed files with 15 additions and 15 deletions

View File

@ -159,8 +159,21 @@ def api_comment(v):
options.append(i.group(1))
body_md = body_md.replace(i.group(0), "")
body_md = CustomRenderer().render(mistletoe.Document(body_md))
body_html = sanitize(body_md)
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
url = request.host_url[:-1] + process_image(name)
body = request.values.get("body") + f"\n![]({url})"
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
else:
body_md = CustomRenderer().render(mistletoe.Document(body_md))
body_html = sanitize(body_md)
bans = filter_comment_html(body_html)
@ -229,19 +242,6 @@ def api_comment(v):
return {"error": "Too much spam!"}, 403
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
url = request.host_url[:-1] + process_image(name)
body = request.values.get("body") + f"\n![]({url})"
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
if len(body_html) > 20000: abort(400)
c = Comment(author_id=v.id,