mirror of
https://github.com/MiSTer-devel/Distribution_MiSTer.git
synced 2026-05-17 03:03:37 +00:00
Improving is_valid_path
This commit is contained in:
committed by
GitHub
parent
2cc3c5a130
commit
a0389fb98f
10
.github/db_operator.py
vendored
10
.github/db_operator.py
vendored
@@ -201,7 +201,15 @@ def is_valid_url(url: str) -> bool:
|
||||
|
||||
def is_valid_path(path: str) -> bool:
|
||||
try:
|
||||
return Path(path).is_relative() and len(path) >= 3
|
||||
p = Path(path)
|
||||
if not p.is_relative() or len(path) < 3:
|
||||
return False
|
||||
|
||||
for part in p.parts:
|
||||
if part in ['..', '.']:
|
||||
return False
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user