This commit is contained in:
dgtlmoon
2025-10-28 11:46:00 +01:00
parent 4e699cc13b
commit f9cd4da2bb

View File

@@ -99,7 +99,7 @@ def is_safe_valid_url(test_url):
# If hosts that only contain alphanumerics are allowed ("localhost" for example) # If hosts that only contain alphanumerics are allowed ("localhost" for example)
allow_simplehost = not strtobool(os.getenv('BLOCK_SIMPLEHOSTS', 'False')) allow_simplehost = not strtobool(os.getenv('BLOCK_SIMPLEHOSTS', 'False'))
try: try:
if not test_url.lower().startswith('file:') and not validators.url(test_url, simple_host=allow_simplehost): if not test_url.strip().lower().startswith('file:') and not validators.url(test_url, simple_host=allow_simplehost):
logger.warning(f'URL "{test_url}" failed validation, aborting.') logger.warning(f'URL "{test_url}" failed validation, aborting.')
return False return False
except validators.ValidationError: except validators.ValidationError: