mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-02 20:32:39 +02:00
feat(obsidian_plugin): validate binary attachments and enforce MIME type checks
This commit is contained in:
parent
3b9be79d65
commit
e84dc87c5b
9 changed files with 275 additions and 40 deletions
|
|
@ -119,8 +119,7 @@ def _build_metadata(
|
|||
}
|
||||
if payload.is_binary:
|
||||
meta["is_binary"] = True
|
||||
if payload.mime_type:
|
||||
meta["mime_type"] = payload.mime_type
|
||||
meta["mime_type"] = payload.mime_type
|
||||
if extra:
|
||||
meta.update(extra)
|
||||
return meta
|
||||
|
|
@ -154,9 +153,6 @@ def _build_document_string(
|
|||
async def _extract_binary_attachment_markdown(
|
||||
payload: NotePayload, *, vision_llm
|
||||
) -> tuple[str, dict[str, Any]]:
|
||||
if not payload.binary_base64:
|
||||
return "", {"attachment_extraction_status": "missing_binary_payload"}
|
||||
|
||||
try:
|
||||
raw_bytes = base64.b64decode(payload.binary_base64, validate=True)
|
||||
except Exception:
|
||||
|
|
@ -208,7 +204,7 @@ async def _run_etl_extract(*, file_path: str, filename: str, vision_llm):
|
|||
|
||||
def _is_image_attachment(payload: NotePayload) -> bool:
|
||||
ext = payload.extension.lower().lstrip(".")
|
||||
return ext in {"png", "jpg", "jpeg", "gif", "webp", "bmp", "tiff", "svg"}
|
||||
return ext in {"png", "jpg", "jpeg", "gif", "webp", "svg"}
|
||||
|
||||
|
||||
async def _resolve_attachment_vision_llm(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue