sfdsfd
This commit is contained in:
parent
2637de952b
commit
0750035557
2 changed files with 24 additions and 5 deletions
|
@ -221,6 +221,9 @@ def post_id(pid, anything=None, v=None):
|
|||
@auth_required
|
||||
@validate_formkey
|
||||
def edit_post(pid, v):
|
||||
if v and v.patron:
|
||||
if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413
|
||||
elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413
|
||||
|
||||
p = get_post(pid)
|
||||
|
||||
|
@ -264,6 +267,16 @@ def edit_post(pid, v):
|
|||
p.title = title
|
||||
p.title_html = title_html
|
||||
|
||||
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)}.webp'
|
||||
file.save(name)
|
||||
url = request.host_url[:-1] + process_image(name)
|
||||
|
||||
body += f"\n\n"
|
||||
|
||||
if body != p.body:
|
||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue