mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
structly validation
This commit is contained in:
@@ -138,7 +138,7 @@ class Storage:
|
||||
|
||||
def __filter(self, items: list[str]) -> Generator[str, None, None]:
|
||||
for item in sorted(map(str.strip, items)):
|
||||
if not item.startswith(".__") and item != "lost+found":
|
||||
if not item.startswith(".") and item != "lost+found":
|
||||
yield item
|
||||
|
||||
def get_image_by_name(self, name: str) -> Image:
|
||||
|
||||
@@ -48,8 +48,6 @@ def valid_msd_image_name(arg: Any) -> str:
|
||||
raise_error(arg, name)
|
||||
for (index, part) in enumerate(list(parts)):
|
||||
parts[index] = valid_printable_filename(part, name=name)
|
||||
if part.startswith(".__") or part == "lost+found":
|
||||
raise_error(part, name)
|
||||
return "/".join(parts)
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,12 @@ def valid_printable_filename(arg: Any, name: str="") -> str:
|
||||
|
||||
arg = valid_stripped_string_not_empty(arg, name)
|
||||
|
||||
if "/" in arg or "\0" in arg or arg in [".", ".."]:
|
||||
if (
|
||||
"/" in arg
|
||||
or "\0" in arg
|
||||
or arg.startswith(".")
|
||||
or arg == "lost+found"
|
||||
):
|
||||
raise_error(arg, name)
|
||||
|
||||
arg = "".join(
|
||||
|
||||
Reference in New Issue
Block a user