Spaces:
Running
Running
Download src/helpers/security.py from sparklabuofu/MiniWeb-demo: direct link, hf CLI and curl.
- Browser
- Download file 317 Bytes
-
https://huggingface.co/spaces/sparklabuofu/MiniWeb-demo/resolve/main/src/helpers/security.py
- Command line
-
hf download hf://spaces/sparklabuofu/MiniWeb-demo/src/helpers/security.py
-
curl -L -o security.py https://huggingface.co/spaces/sparklabuofu/MiniWeb-demo/resolve/main/src/helpers/security.py
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 | |