raise overall content body size, routes will implement stricter limits

This commit is contained in:
2025-12-06 10:18:32 +03:00
parent 6c96563a0e
commit 09a19b5352
3 changed files with 12 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ import time
import re
import os
AVATAR_MAX_SIZE = 1000 * 1000
bp = Blueprint("users", __name__, url_prefix = "/users/")
@@ -451,6 +453,14 @@ def set_avatar(username):
flash('Avatar missing.', InfoboxKind.ERROR)
return redirect(url_for('.settings', username=user.username))
file.seek(0, os.SEEK_END)
file_size = file.tell()
file.seek(0, os.SEEK_SET)
if file_size > AVATAR_MAX_SIZE:
flash('Avatar image is over 1MB.', InfoboxKind.ERROR)
return redirect(url_for('.settings', username=user.username))
file_bytes = file.read()
now = int(time.time())