Standardize fuzzy matching and use fullmatch
Solves two problems: 1. How match fuzziness was used was very inconsistent; make them all the same, i.e. "if is_fuzzy and limit, apply .* to both sides". 2. Use re.fullmatch instead of re.match to ensure exact matching of the regex to the value. Without fuzziness, this would sometimes cause inconsistent behavior, for instance if a limit was non-fuzzy "vm", expecting to match the actual "vm", but also matching "vm1" too.
This commit is contained in:
@ -1227,9 +1227,9 @@ def get_list(zkhandler, node, state, tag, limit, is_fuzzy=True, negate=False):
|
||||
if limit:
|
||||
# Try to match the limit against the UUID (if applicable) and name
|
||||
try:
|
||||
if is_limit_uuid and re.match(limit, vm):
|
||||
if is_limit_uuid and re.fullmatch(limit, vm):
|
||||
is_limit_match = True
|
||||
if re.match(limit, name):
|
||||
if re.fullmatch(limit, name):
|
||||
is_limit_match = True
|
||||
except Exception as e:
|
||||
return False, "Regex Error: {}".format(e)
|
||||
|
Reference in New Issue
Block a user