Skip to content

Commit 74070be

Browse files
committed
change domain validation scheme
2 parents 0e92dc7 + aaed42e commit 74070be

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

.DS_Store

-12 KB
Binary file not shown.

install.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
if [ -f "/etc/os-release" ]; then
3+
if [ -f "/etc/os-release" ]; then
44
. /etc/os-release
55
else
66
ID="unsupported"
@@ -11,28 +11,32 @@ if [ "$ID" = "ubuntu" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then
1111
export DEBIAN_FRONTEND=noninteractive
1212
apt -q -y -o Dpkg::Options::=--force-confnew update
1313
apt -q -y -o Dpkg::Options::=--force-confnew install wget curl
14-
SERVER_OS="$NAME"
14+
SERVER_OS="Ubuntu"
1515
elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then
1616
case "$VERSION_ID" in
1717
7|7.*)
1818
yum install curl wget -y 1> /dev/null
1919
yum update curl wget ca-certificates -y 1> /dev/null
20-
SERVER_OS="$NAME"
20+
if [ "$ID" = "centos" ]; then
21+
SERVER_OS="CentOS"
22+
else
23+
SERVER_OS="CloudLinux"
24+
fi
2125
;;
2226
8|8.*)
2327
printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n'
2428
yum install curl wget -y 1> /dev/null
2529
yum update curl wget ca-certificates -y 1> /dev/null
26-
SERVER_OS="${NAME}${VERSION_ID}"
30+
SERVER_OS="CentOS8"
2731
;;
2832
esac
29-
else
33+
else
3034
printf >&2 '\nYour OS -- %s -- is not currently supported!\n' "$PRETTY_NAME"
3135
printf >&2 '\nCyberPanel is currently supported on Ubuntu 18.04, CentOS 7 and CloudLinux 7.\n'
3236
exit 1
3337
fi
3438

35-
rm -f cyberpanel.sh install.tar.gz
39+
rm -f cyberpanel.sh install.tar.gz
3640
curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&${SERVER_OS}" 2>/dev/null
3741
chmod +x cyberpanel.sh
3842
./cyberpanel.sh "$@"

requirments.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ urllib3==1.22
6262
websocket-client==0.56.0
6363
zope.component==4.4.1
6464
zope.event==4.3.0
65-
zope.interface==4.5.0
65+
zope.interface==4.5.0
66+
validators==0.14.2

websiteFunctions/website.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
from ApachController.ApacheVhosts import ApacheVhost
3737
from plogical.vhostConfs import vhostConfs
3838
from plogical.cronUtil import CronUtil
39-
from re import match,I,M
4039
from plogical import randomPassword
4140
from .StagingSetup import StagingSetup
41+
import validators
4242

4343

4444
class WebsiteManager:
@@ -180,14 +180,13 @@ def submitWebsiteCreation(self, userID=None, data=None):
180180
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
181181

182182

183-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
184-
M | I):
183+
184+
if not validators.domain(domain):
185185
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
186186
json_data = json.dumps(data_ret)
187187
return HttpResponse(json_data)
188188

189-
if not match(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', adminEmail,
190-
M | I):
189+
if not validators.email(adminEmail):
191190
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."}
192191
json_data = json.dumps(data_ret)
193192
return HttpResponse(json_data)
@@ -267,8 +266,8 @@ def submitDomainCreation(self, userID=None, data=None):
267266
path = data['path']
268267
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
269268

270-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
271-
M | I):
269+
270+
if not validators.domain(domain):
272271
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
273272
json_data = json.dumps(data_ret)
274273
return HttpResponse(json_data)
@@ -1635,8 +1634,7 @@ def submitAliasCreation(self, userID=None, data=None):
16351634
aliasDomain = data['aliasDomain']
16361635
ssl = data['ssl']
16371636

1638-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', aliasDomain,
1639-
M | I):
1637+
if not validators.domain(aliasDomain):
16401638
data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."}
16411639
json_data = json.dumps(data_ret)
16421640
return HttpResponse(json_data)
@@ -2725,14 +2723,14 @@ def startCloning(self, userID=None, data=None):
27252723

27262724
self.domain = data['masterDomain']
27272725

2728-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', self.domain,
2729-
M | I):
2726+
2727+
if not validators.domain(self.domain):
27302728
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
27312729
json_data = json.dumps(data_ret)
27322730
return HttpResponse(json_data)
27332731

2734-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['domainName'],
2735-
M | I):
2732+
2733+
if not validators.domain(data['domainName']):
27362734
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
27372735
json_data = json.dumps(data_ret)
27382736
return HttpResponse(json_data)
@@ -2798,8 +2796,8 @@ def startSync(self, userID=None, data=None):
27982796
currentACL = ACLManager.loadedACL(userID)
27992797
admin = Administrator.objects.get(pk=userID)
28002798

2801-
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['childDomain'],
2802-
M | I):
2799+
2800+
if not validators.domain(data['childDomain']):
28032801
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
28042802
json_data = json.dumps(data_ret)
28052803
return HttpResponse(json_data)
@@ -2870,4 +2868,4 @@ def convertDomainToSite(self, userID=None, request=None):
28702868
except BaseException as msg:
28712869
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
28722870
json_data = json.dumps(data_ret)
2873-
return HttpResponse(json_data)
2871+
return HttpResponse(json_data)

0 commit comments

Comments
 (0)