1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add ALLOWED_URL_SCHEMES

This commit is contained in:
jeremystretch
2021-10-26 10:24:33 -04:00
parent 7c0f32e8ee
commit 559dc2f865
6 changed files with 26 additions and 16 deletions

View File

@@ -1,9 +1,10 @@
import re
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import _lazy_re_compile, BaseValidator, URLValidator
from netbox.config import Config
class EnhancedURLValidator(URLValidator):
"""
@@ -19,7 +20,11 @@ class EnhancedURLValidator(URLValidator):
r'(?::\d{2,5})?' # Port number
r'(?:[/?#][^\s]*)?' # Path
r'\Z', re.IGNORECASE)
schemes = settings.ALLOWED_URL_SCHEMES
def __init__(self, schemes=None, **kwargs):
super().__init__(**kwargs)
if schemes is not None:
self.schemes = Config().ALLOWED_URL_SCHEMES
class ExclusionValidator(BaseValidator):