From 79895a1ce4ef0b6d7966b1b09f73a0e84b289c5c Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Wed, 12 Nov 2025 16:58:07 -0600 Subject: [PATCH] Enhancement: Update URL validation to support authentication for non-FQDN hostnames in rtsp/rtp/udp URLs --- core/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/utils.py b/core/utils.py index f21e734b..38b31144 100644 --- a/core/utils.py +++ b/core/utils.py @@ -379,11 +379,12 @@ def validate_flexible_url(value): # More flexible pattern for non-FQDN hostnames with paths # Matches: http://hostname, https://hostname/, http://hostname:port/path/to/file.xml, rtp://192.168.2.1, rtsp://192.168.178.1, udp://239.0.0.1:1234 # Also matches FQDNs for rtsp/rtp/udp protocols: rtsp://FQDN/path?query=value - non_fqdn_pattern = r'^(rts?p|https?|udp)://([a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?|[0-9.]+)?(\:[0-9]+)?(/[^\s]*)?$' + # Also supports authentication: rtsp://user:pass@hostname/path + non_fqdn_pattern = r'^(rts?p|https?|udp)://([a-zA-Z0-9_\-\.]+:[^\s@]+@)?([a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?|[0-9.]+)?(\:[0-9]+)?(/[^\s]*)?$' non_fqdn_match = re.match(non_fqdn_pattern, value) if non_fqdn_match: - return # Accept non-FQDN hostnames and rtsp/rtp/udp URLs + return # Accept non-FQDN hostnames and rtsp/rtp/udp URLs with optional authentication # If it doesn't match our flexible patterns, raise the original error raise ValidationError("Enter a valid URL.")