From f130ec0bf333bc4a29bd27f50955e37d23a8d396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Wed, 18 Mar 2020 09:46:21 +0100 Subject: [PATCH] gui: improvements of feature keyboard layout checks --- qubes/ext/gui.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qubes/ext/gui.py b/qubes/ext/gui.py index feacb221..35ff5902 100644 --- a/qubes/ext/gui.py +++ b/qubes/ext/gui.py @@ -126,16 +126,18 @@ class GUI(qubes.ext.Extension): def on_feature_pre_set(self, subject, event, feature, value, oldvalue=None): untrusted_xkb_layout = value.split('+') if not len(untrusted_xkb_layout) == 3: - raise qubes.exc.QubesValueError + raise qubes.exc.QubesValueError("Invalid number of parameters") untrusted_layout = untrusted_xkb_layout[0] untrusted_variant = untrusted_xkb_layout[1] untrusted_options = untrusted_xkb_layout[2] - re_variant = '^[a-zA-Z0-9-_]+$' - re_options = '^[a-zA-Z0-9-_:,]+$' + re_variant = r'^[a-zA-Z0-9-_]*$' + re_options = r'^[a-zA-Z0-9-_:,]*$' - if not untrusted_layout.isalpha() or \ - not bool(re.match(re_variant, untrusted_variant)) or \ - not bool(re.match(re_options, untrusted_options)): - raise qubes.exc.QubesValueError + if not untrusted_layout.isalpha(): + raise qubes.exc.QubesValueError("Invalid layout provided") + if not bool(re.match(re_variant, untrusted_variant)): + raise qubes.exc.QubesValueError("Invalid variant provided") + if not bool(re.match(re_options, untrusted_options)): + raise qubes.exc.QubesValueError("Invalid options provided")