summaryrefslogtreecommitdiff
path: root/kvmd/validators/kvm.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/validators/kvm.py')
-rw-r--r--kvmd/validators/kvm.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py
index e99929af..29b45500 100644
--- a/kvmd/validators/kvm.py
+++ b/kvmd/validators/kvm.py
@@ -20,10 +20,13 @@
# ========================================================================== #
+import re
+
from typing import Any
from .. import keymap
+from . import check_not_none_string
from . import check_string_in_list
from .basic import valid_number
@@ -38,6 +41,18 @@ def valid_atx_button(arg: Any) -> str:
return check_string_in_list(arg, "ATX button", ["power", "power_long", "reset"])
+def valid_msd_image_name(arg: Any) -> str:
+ if len(str(arg).strip()) == 0:
+ arg = None
+ arg = check_not_none_string(arg, "MSD image name", strip=True)
+ arg = re.sub(r"[^\w\.+@()\[\]-]", "_", arg)
+ if arg == ".":
+ arg = "_"
+ if arg == "..":
+ arg = "__"
+ return arg[:255]
+
+
def valid_log_seek(arg: Any) -> int:
return int(valid_number(arg, min=0, name="log seek"))