Merge "Beef up sysinv URL validator"
This commit is contained in:
commit
1fb8181008
@ -1,2 +1,2 @@
|
||||
SRC_DIR="sysinv"
|
||||
TIS_PATCH_VER=324
|
||||
TIS_PATCH_VER=325
|
||||
|
@ -25,6 +25,7 @@ Requires: python-pbr
|
||||
Requires: python-webtest
|
||||
Requires: python-wsme
|
||||
Requires: python-six
|
||||
Requires: python2-django
|
||||
Requires: python2-mox3
|
||||
Requires: python2-oslo-config
|
||||
Requires: python2-oslo-concurrency
|
||||
|
@ -15,6 +15,7 @@ Package: sysinv
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends},
|
||||
${python:Depends},
|
||||
python-django,
|
||||
python-docker,
|
||||
python-parted,
|
||||
python-six,
|
||||
|
@ -40,3 +40,5 @@ rpm
|
||||
ruamel.yaml>=0.13.14 # MIT
|
||||
docker # Apache-2.0
|
||||
kubernetes # Apache-2.0
|
||||
Django<2,>=1.11.20 # BSD
|
||||
|
||||
|
@ -51,6 +51,7 @@ import uuid
|
||||
import wsme
|
||||
import yaml
|
||||
|
||||
from django.core.validators import URLValidator
|
||||
from eventlet.green import subprocess
|
||||
from eventlet import greenthread
|
||||
import netaddr
|
||||
@ -1769,20 +1770,10 @@ def is_openstack_applied(dbapi):
|
||||
|
||||
|
||||
def is_url(url_str):
|
||||
# Django URL validation patterns
|
||||
r = re.compile(
|
||||
r'^(?:http|ftp)s?://' # http:// or https://
|
||||
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)' # domain...
|
||||
r'+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
|
||||
r'localhost|' # localhost...
|
||||
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
|
||||
r'(?::\d+)?' # optional port
|
||||
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
|
||||
|
||||
url = r.match(url_str)
|
||||
if url:
|
||||
try:
|
||||
URLValidator()(url_str)
|
||||
return True
|
||||
else:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user