def isSafeUrl(target):
""" Checks URL for safety to ensure that it does not redirect unexpectedly.
Args:
target (str): URL for the target to test.
Returns:
bool: True if the URL is safe.
"""
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
###################################################
评论列表
文章目录