Skip to content

Commit aaf5d5a

Browse files
feat: Check content type, handle more errs
1 parent 0d874bd commit aaf5d5a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ietf/api/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ def _err(code, text):
620620
if request.method != "POST":
621621
return _err(405, "Method not allowed")
622622

623+
if request.content_type != "application/json":
624+
return _err(415, "Content-Type must be application/json")
625+
623626
# Validate
624627
try:
625628
payload = json.loads(request.body)
@@ -628,6 +631,8 @@ def _err(code, text):
628631
return _err(400, f"JSON parse error at line {err.lineno} col {err.colno}: {err.msg}")
629632
except jsonschema.exceptions.ValidationError as err:
630633
return _err(400, f"JSON schema error at {err.json_path}: {err.message}")
634+
except Exception:
635+
return _err(400, "Invalid request format")
631636

632637
try:
633638
message = base64.b64decode(payload["message"], validate=True)

0 commit comments

Comments
 (0)