MiniWeb-demo / src /helpers /security.py
sparklabuofu's picture
Update the demo
22de727 verified
Raw History Blame Contribute Delete
317 Bytes
"""Web security helpers."""
def safe_next(value):
"""Return `value` only if it's a same-site relative path (open-redirect
guard); otherwise None. Rejects absolute URLs and protocol-relative `//`."""
if value and value.startswith("/") and not value.startswith("//"):
return value
return None