diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index db680f6a4..000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/install.sh b/install.sh index 903bac16d..635300c83 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ -f "/etc/os-release" ]; then +if [ -f "/etc/os-release" ]; then . /etc/os-release else ID="unsupported" @@ -11,28 +11,32 @@ if [ "$ID" = "ubuntu" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then export DEBIAN_FRONTEND=noninteractive apt -q -y -o Dpkg::Options::=--force-confnew update apt -q -y -o Dpkg::Options::=--force-confnew install wget curl - SERVER_OS="$NAME" + SERVER_OS="Ubuntu" elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then case "$VERSION_ID" in 7|7.*) yum install curl wget -y 1> /dev/null yum update curl wget ca-certificates -y 1> /dev/null - SERVER_OS="$NAME" + if [ "$ID" = "centos" ]; then + SERVER_OS="CentOS" + else + SERVER_OS="CloudLinux" + fi ;; 8|8.*) printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n' yum install curl wget -y 1> /dev/null yum update curl wget ca-certificates -y 1> /dev/null - SERVER_OS="${NAME}${VERSION_ID}" + SERVER_OS="CentOS8" ;; esac -else +else printf >&2 '\nYour OS -- %s -- is not currently supported!\n' "$PRETTY_NAME" printf >&2 '\nCyberPanel is currently supported on Ubuntu 18.04, CentOS 7 and CloudLinux 7.\n' exit 1 fi -rm -f cyberpanel.sh install.tar.gz +rm -f cyberpanel.sh install.tar.gz curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&${SERVER_OS}" 2>/dev/null chmod +x cyberpanel.sh ./cyberpanel.sh "$@" diff --git a/requirments.txt b/requirments.txt index 5b673b52f..c9609dff5 100755 --- a/requirments.txt +++ b/requirments.txt @@ -62,4 +62,5 @@ urllib3==1.22 websocket-client==0.56.0 zope.component==4.4.1 zope.event==4.3.0 -zope.interface==4.5.0 \ No newline at end of file +zope.interface==4.5.0 +validators==0.14.2 diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index ea99d4bb8..e58e8e158 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -36,9 +36,9 @@ from managePHP.phpManager import PHPManager from ApachController.ApacheVhosts import ApacheVhost from plogical.vhostConfs import vhostConfs from plogical.cronUtil import CronUtil -from re import match,I,M from plogical import randomPassword from .StagingSetup import StagingSetup +import validators class WebsiteManager: @@ -180,14 +180,13 @@ class WebsiteManager: return ACLManager.loadErrorJson('createWebSiteStatus', 0) - if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain, - M | I): + + if not validators.domain(domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) - if not match(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', adminEmail, - M | I): + if not validators.email(adminEmail): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -267,8 +266,8 @@ class WebsiteManager: path = data['path'] tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain, - M | I): + + if not validators.domain(domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1635,8 +1634,7 @@ class WebsiteManager: aliasDomain = data['aliasDomain'] ssl = data['ssl'] - if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', aliasDomain, - M | I): + if not validators.domain(aliasDomain): data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2725,14 +2723,14 @@ StrictHostKeyChecking no self.domain = data['masterDomain'] - 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, - M | I): + + if not validators.domain(self.domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) - 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'], - M | I): + + if not validators.domain(data['domainName']): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2798,8 +2796,8 @@ StrictHostKeyChecking no currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) - 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'], - M | I): + + if not validators.domain(data['childDomain']): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2870,4 +2868,4 @@ StrictHostKeyChecking no except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return HttpResponse(json_data)