Classify invalid image content types
This commit is contained in:
+6
-1
@@ -102,7 +102,12 @@ def fetch_url_bytes(url: str, timeout: float = 10.0, max_bytes: int = DEFAULT_MA
|
||||
|
||||
content_type = (r.headers.get("content-type") or "").lower()
|
||||
if content_type and not content_type.startswith("image/"):
|
||||
raise ImageLoadError(f"URL does not point to an image content type: {content_type}")
|
||||
raise _error(
|
||||
f"URL does not point to an image content type: {content_type}",
|
||||
category="invalid_content_type",
|
||||
stage="fetch",
|
||||
metadata={"content_type": content_type, "remote_status": r.status_code},
|
||||
)
|
||||
|
||||
buf = io.BytesIO()
|
||||
total = 0
|
||||
|
||||
Reference in New Issue
Block a user