INNER CODE UNIT · Python

_resolve_static_asset_path

Soju06/codex-lb · app/main.py:366

def _resolve_static_asset_path(static_root: Path, requested_path: str) -> Path | None:
    """Return a filesystem path for a SPA asset only when it stays under static_root."""
    normalized = PurePosixPath(requested_path)
    if normalized.is_absolute() or ".." in normalized.parts:
        return None
    full_path, stat_result = _static_files_for_root(static_root).lookup_path(normalized.as_posix())
    if stat_result is None or not stat.S_ISREG(stat_result.st_mode):
        return None
    return Path(full_path)


def _is_metrics_bind_conflict(exc: BaseException) -> bool:
    if isinstance(exc, SystemExit):
        return exc.code == 1
    if isinstance(exc, OSError):
        import errno as _errno

        return exc.errno in (_errno.EADDRINUSE, _errno.EADDRNOTAVAIL)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…