From 56c2b77f25aafdd23000d7884af0934a9203b276 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Mon, 18 May 2026 17:38:49 -0700 Subject: [PATCH] Improve device query validation --- src/GamUpdate.txt | 4 ++++ src/gam/__init__.py | 10 ++++++++-- src/gam/gamlib/glmsgs.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 14df3863..e25b9fcd 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,7 @@ +7.43.07 + +Improved validation of ``, `` and ``. + 7.43.06 Updated commands that use ``, `` or `` to validate diff --git a/src/gam/__init__.py b/src/gam/__init__.py index af14e421..4699c270 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki """ __author__ = 'GAM Team ' -__version__ = '7.43.06' +__version__ = '7.43.07' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' # pylint: disable=wrong-import-position @@ -6072,7 +6072,13 @@ def getQueries(myarg): return shlexSplitList(getString(Cmd.OB_QUERY_LIST)) def _validateDeviceQuery(entityType, query): - if (':' not in query) or ('?' in query): + if ':' in query: + qfield, qvalue = query.split(':', 1) + qfield = qfield.strip() + else: + qfield = '' + qvalue = query + if (not qfield) or (not qvalue) or ('?' in query): Cmd.Backup() usageErrorExit(Msg.INVALID_DEVICE_QUERY.format(Ent.Singular(entityType), query)) diff --git a/src/gam/gamlib/glmsgs.py b/src/gam/gamlib/glmsgs.py index b490aedd..3b49dc88 100644 --- a/src/gam/gamlib/glmsgs.py +++ b/src/gam/gamlib/glmsgs.py @@ -312,7 +312,7 @@ INVALID_ALIAS = 'Invalid Alias' INVALID_ATTENDEE_CHANGE = 'Invalid attendee change "{0}"' INVALID_CHARSET = 'Invalid charset "{0}"' INVALID_DATE_TIME_RANGE = '{0} {1} must be greater than/equal to {2} {3}' -INVALID_DEVICE_QUERY = 'Invalid {0} query "{1}"; it must contain a ":" and must not contain a "?"' +INVALID_DEVICE_QUERY = 'Invalid {0} query "{1}"; it must be if the form "field:value" and must not contain a "?"' INVALID_EMOJI_NAME = '{0} does not match pattern :[0-9a-z_-]:' INVALID_ENTITY = 'Invalid {0}, {1}' INVALID_EVENT_TIMERANGE = '{0} {1} must be less than {2}'