mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 20:18:38 -06:00
fix(utilities): Allow single-digit port numbers in URL validator
Change port number regex from `\d{2,5}` to `\d{1,5}` to permit valid
single-digit ports (1-9). This aligns with RFC 3986 and fixes
validation for URLs using ports like :8 or :9.
Fixes #21698
This commit is contained in:
@@ -34,7 +34,7 @@ class EnhancedURLValidator(URLValidator):
|
||||
r'^(?:[a-z0-9\.\-\+]*)://' # Scheme (enforced separately)
|
||||
r'(?:\S+(?::\S*)?@)?' # HTTP basic authentication
|
||||
r'(?:' + '|'.join(host_res) + ')' # IPv4, IPv6, FQDN, or hostname
|
||||
r'(?::\d{2,5})?' # Port number
|
||||
r'(?::\d{1,5})?' # Port number
|
||||
r'(?:[/?#][^\s]*)?' # Path
|
||||
r'\Z', re.IGNORECASE)
|
||||
schemes = None
|
||||
|
||||
Reference in New Issue
Block a user