Close medium exposure on reports, registration, uploads, and exercise HTML.
Deploy Development / deploy (push) Successful in 59s
Test Suite / pytest-backend (push) Failing after 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Failing after 7m48s
Deploy Development / deploy (push) Successful in 59s
Test Suite / pytest-backend (push) Failing after 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Failing after 7m48s
A superadmin can also turn off another account''s two-factor when the authenticator is lost. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5ea225ec6b
commit
f10c28e5cd
20 files changed
+480
-247
No files matched your search
@@ -163,24 +163,9 @@ ALLOWED_UPLOAD_MIMES = frozenset(
|
||||
}
|
||||
)
|
||||
|
||||
# Dateiendung → MIME wenn der Client keinen sinnvollen Content-Type sendet (häufig mobil / iOS).
|
||||
_UPLOAD_FILENAME_MIME_FALLBACK = {
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".png": "image/png",
|
||||
".gif": "image/gif",
|
||||
".heic": "image/heic",
|
||||
".heif": "image/heif",
|
||||
".mp4": "video/mp4",
|
||||
".mov": "video/quicktime",
|
||||
".pdf": "application/pdf",
|
||||
}
|
||||
|
||||
|
||||
def _sniff_allowed_upload_mime(raw: bytes) -> Optional[str]:
|
||||
"""Erkennt erlaubte MIME-Typen anhand weniger Magic Bytes (ohne Pillow/python-magic)."""
|
||||
if len(raw) < 12:
|
||||
return None
|
||||
if raw[:3] == b"\xff\xd8\xff":
|
||||
return "image/jpeg"
|
||||
if raw[:8] == b"\x89PNG\r\n\x1a\n":
|
||||
@@ -189,7 +174,7 @@ def _sniff_allowed_upload_mime(raw: bytes) -> Optional[str]:
|
||||
return "image/gif"
|
||||
if raw[:4] == b"%PDF":
|
||||
return "application/pdf"
|
||||
if raw[4:8] != b"ftyp":
|
||||
if len(raw) < 12 or raw[4:8] != b"ftyp":
|
||||
return None
|
||||
brand = raw[8:12]
|
||||
# HEIC / HEIF (u. a. iPhone „高效率“)
|
||||
@@ -208,17 +193,11 @@ def resolve_upload_mime_type(
|
||||
content_type: Optional[str],
|
||||
filename: Optional[str],
|
||||
) -> str:
|
||||
"""Ermittelt ein erlaubtes MIME (Client-Header, Magic Bytes oder Dateiendung)."""
|
||||
ct = (content_type or "").split(";")[0].strip().lower()
|
||||
if ct in ALLOWED_UPLOAD_MIMES:
|
||||
return ct
|
||||
"""MIME nur aus dem Dateiinhalt. Client-Header und Dateiendung entscheiden nicht."""
|
||||
guessed = _sniff_allowed_upload_mime(raw)
|
||||
if guessed in ALLOWED_UPLOAD_MIMES:
|
||||
return guessed
|
||||
ext = Path(filename or "").suffix.lower()
|
||||
fb = _UPLOAD_FILENAME_MIME_FALLBACK.get(ext)
|
||||
if fb in ALLOWED_UPLOAD_MIMES:
|
||||
return fb
|
||||
ct = (content_type or "").split(";")[0].strip().lower()
|
||||
raise ValueError(f"Dateityp nicht erlaubt: {ct or 'unbekannt'}")
|
||||
|
||||
|
||||
@@ -3083,16 +3062,28 @@ def delete_exercise_variant(
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
def _content_disposition_inline(filename: Optional[str]) -> str:
|
||||
"""Inline-Darstellung im Browser (<video>/<img>), keine attachment-Download-Leiste."""
|
||||
def _safe_download_name(filename: Optional[str]) -> str:
|
||||
"""Dateiname ohne Steuerzeichen und ohne Anführungszeichen für Content-Disposition."""
|
||||
if not filename:
|
||||
return "inline"
|
||||
fn = str(filename).strip()
|
||||
return ""
|
||||
cleaned = []
|
||||
for ch in str(filename):
|
||||
if ch < " " or ch == "\x7f" or ch in {'"', "\\", ";"}:
|
||||
continue
|
||||
cleaned.append(ch)
|
||||
return "".join(cleaned).strip()[:180]
|
||||
|
||||
|
||||
def _content_disposition(filename: Optional[str], *, attachment: bool) -> str:
|
||||
"""Bilder und Videos inline. PDF als Anhang. Dateiname ohne Steuerzeichen."""
|
||||
disposition = "attachment" if attachment else "inline"
|
||||
fn = _safe_download_name(filename)
|
||||
if not fn:
|
||||
return disposition
|
||||
quoted = quote(fn, safe="")
|
||||
escaped = fn.replace('"', "\\")
|
||||
if quoted != fn:
|
||||
return f"inline; filename*=utf-8''{quoted}"
|
||||
return f'inline; filename="{escaped}"'
|
||||
return f"{disposition}; filename*=utf-8''{quoted}"
|
||||
return f'{disposition}; filename="{fn}"'
|
||||
|
||||
|
||||
def _parse_bytes_range_single(range_header: str, file_size: int) -> Optional[Tuple[int, int]]:
|
||||
@@ -3152,7 +3143,10 @@ def _binary_media_response(
|
||||
path_str = str(path_arg.resolve())
|
||||
stat_r = os.stat(path_str)
|
||||
file_size = int(stat_r.st_size)
|
||||
cd_val = _content_disposition_inline(download_name)
|
||||
cd_val = _content_disposition(
|
||||
download_name,
|
||||
attachment=(mime_type or "").split(";")[0].strip().lower() == "application/pdf",
|
||||
)
|
||||
base_h = {"accept-ranges": "bytes", "content-disposition": cd_val}
|
||||
|
||||
if request.method.upper() == "HEAD":
|
||||
|
||||
Reference in new issue
Block a user