From 5ba0873c32be21fdff822dcac47095d944a29cd3 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Tue, 8 Sep 2020 11:35:29 +0300 Subject: stronger validators --- kvmd/validators/kvm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'kvmd/validators/kvm.py') diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py index fe9a8a8e..17895c47 100644 --- a/kvmd/validators/kvm.py +++ b/kvmd/validators/kvm.py @@ -28,6 +28,7 @@ from ..keyboard.mappings import KEYMAP from . import raise_error from . import check_string_in_list from . import check_re_match +from . import check_len from .basic import valid_stripped_string_not_empty from .basic import valid_number @@ -92,7 +93,8 @@ def valid_hid_mouse_wheel(arg: Any) -> int: # ===== def valid_ugpio_driver(arg: Any) -> str: - return check_re_match(arg, "GPIO driver", r"^[a-zA-Z_][a-zA-Z0-9_-]*$")[:255] + name = "GPIO driver" + return check_len(check_re_match(arg, name, r"^[a-zA-Z_][a-zA-Z0-9_-]*$"), name, 255) def valid_ugpio_mode(arg: Any) -> str: @@ -100,7 +102,8 @@ def valid_ugpio_mode(arg: Any) -> str: def valid_ugpio_channel(arg: Any) -> str: - return check_re_match(arg, "GPIO channel", r"^[a-zA-Z_][a-zA-Z0-9_-]*$")[:255] + name = "GPIO channel" + return check_len(check_re_match(arg, name, r"^[a-zA-Z_][a-zA-Z0-9_-]*$"), name, 255) def valid_ugpio_view_table(arg: Any) -> List[List[str]]: -- cgit v1.2.3