diff --git a/domain_check.py b/domain_check.py index 26cbc1a..0414b53 100644 --- a/domain_check.py +++ b/domain_check.py @@ -1,8 +1,15 @@ +from re import compile, sub + def domain_ok(domain): domains = ["jet"] if domain.count(".") == 1: if domain.split(".")[1] in domains: - return True + # ../some => some + # Защита от проверки папок выше, чем нужно и др. + regex = compile('[^a-zA-Zа-яА-ЯЁё.]') + c_domain = regex.sub('', domain) + if domain == c_domain: + return domain return False diff --git a/network.py b/network.py index f1a93cc..5e66e7a 100644 --- a/network.py +++ b/network.py @@ -10,6 +10,7 @@ from shutil import unpack_archive from re import compile, sub from verify import * +from domain_check import * # Здесь идёт обработка всех запросов через сеть @@ -29,18 +30,6 @@ def port_gen(): port = randint(4000, 4200) return port -# ../some => some -# Защита от проверки папок выше, чем нужно и др. -def v_check(check): - regex = compile('[^a-zA-Zа-яА-ЯЁё.]') - check = regex.sub('', check) - - if check.count('.') > 1: - return 'BAD' - - return check - - def server_http(): os.chdir("cached") @@ -73,7 +62,7 @@ def server(http_port): check = op[3:] print(check) # Защита от доступа выше - check = v_check(check) + check = domain_ok(check) print(check) if os.path.exists(f'cached/{check}'):