MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / safe_image_filename

Function safe_image_filename

scripts/write_obsidian_note.py:57–67  ·  view source on GitHub ↗
(filename: str, source_image: Path)

Source from the content-addressed store, hash-verified

55
56
57def safe_image_filename(filename: str, source_image: Path) -> str:
58 candidate = filename.strip() or source_image.name
59 if (
60 not candidate
61 or candidate in {".", ".."}
62 or "/" in candidate
63 or "\\" in candidate
64 or Path(candidate).is_absolute()
65 ):
66 raise SystemExit(f"Unsafe figure image filename in insert decision: {candidate}")
67 return candidate
68
69
70def embed_target_matches(target: str, expected_relative: str) -> bool:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected