Resolve *filename* within session.output_dir, guarding against traversal.
(session: SessionState, filename: str)
| 30 | |
| 31 | |
| 32 | def _safe_doc_path(session: SessionState, filename: str) -> Path | None: |
| 33 | """Resolve *filename* within session.output_dir, guarding against traversal.""" |
| 34 | if not filename.endswith(".md"): |
| 35 | filename += ".md" |
| 36 | output_base = Path(session.output_dir).resolve() |
| 37 | doc_path = (output_base / filename).resolve() |
| 38 | if not _is_within(doc_path, output_base): |
| 39 | return None |
| 40 | return doc_path |
| 41 | |
| 42 | |
| 43 | def _ensure_parent_dirs(path: Path) -> None: |
no test coverage detected