From 21723e29bcbddd9b81cb8a729e4896372d719d54 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 11 Nov 2025 17:17:01 -0600 Subject: [PATCH] Update URL validation to support FQDNs for rtsp/rtp protocols and improve regex pattern for flexibility. --- core/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/utils.py b/core/utils.py index da40d19c..fac8a557 100644 --- a/core/utils.py +++ b/core/utils.py @@ -377,12 +377,13 @@ def validate_flexible_url(value): import re # More flexible pattern for non-FQDN hostnames with paths - # Matches: http://hostname, http://hostname/, http://hostname:port/path/to/file.xml, rtp://192.168.2.1, rtsp://192.168.178.1 - non_fqdn_pattern = r'^(rts?p|https?)://([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])|[0-9.]+)?(\:[0-9]+)?(/[^\s]*)?$' + # Matches: http://hostname, https://hostname/, http://hostname:port/path/to/file.xml, rtp://192.168.2.1, rtsp://192.168.178.1 + # Also matches FQDNs for rtsp/rtp protocols: rtsp://FQDN/path?query=value + non_fqdn_pattern = r'^(rts?p|https?)://([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 + return # Accept non-FQDN hostnames and rtsp/rtp URLs # If it doesn't match our flexible patterns, raise the original error raise ValidationError("Enter a valid URL.")