def is_safe_url(target):
ref_url = urlparse(request.host_url)
test_url = urlparse(urljoin(request.host_url, target))
is_safe = test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc
return is_safe
文章目录