(file_path: str)
| 245 | return rel_path |
| 246 | |
| 247 | def _parse_file_path(file_path: str) -> str: |
| 248 | file_path = _normalize_relative_path(file_path) |
| 249 | if not file_path: |
| 250 | raise ValueError("file_path is missing.") |
| 251 | if file_path.startswith("/"): |
| 252 | raise ValueError(f"Absolute file_path rejected: {file_path!r}") |
| 253 | if _has_parent_reference(file_path): |
| 254 | raise ValueError(f"Path traversal rejected: {file_path!r}") |
| 255 | ext = os.path.splitext(file_path)[1].lower() |
| 256 | if ext not in _ALLOWED_EXTENSIONS: |
| 257 | raise ValueError( |
| 258 | f"File type not allowed: {file_path!r}" |
| 259 | f" (allowed: {', '.join(sorted(_ALLOWED_EXTENSIONS))})" |
| 260 | ) |
| 261 | return file_path |
| 262 | |
| 263 | def _resolve_under_dir(root_dir: Path, rel_path: str) -> Path: |
| 264 | file_path = root_dir / rel_path |
nothing calls this directly
no test coverage detected