This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/utils.py
Santiago L 3af67fee01 Implement user login based on sessions
Use Flask-Login & Flask-WTF libraries
2021-12-28 09:39:12 +01:00

9 lines
275 B
Python

from urllib.parse import urljoin, urlparse
def is_safe_url(request, target):
ref_url = urlparse(request.host_url)
test_url = urlparse(urljoin(request.host_url, target))
return test_url.scheme in ('http', 'https') and \
ref_url.netloc == test_url.netloc