From 2c082e9dfbddd0dcfd07c061edceeacf0f0332a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 5 Jan 2024 21:18:28 -0500 Subject: [PATCH] python: Use a safer regex for range checks --- python/grass/pygrass/modules/interface/parameter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/grass/pygrass/modules/interface/parameter.py b/python/grass/pygrass/modules/interface/parameter.py index 499bc4748e6..7ab67c186ad 100644 --- a/python/grass/pygrass/modules/interface/parameter.py +++ b/python/grass/pygrass/modules/interface/parameter.py @@ -176,7 +176,8 @@ def __init__(self, xparameter=None, diz=None): try: # Check for integer ranges: "3-30" or float ranges: "0.0-1.0" isrange = re.match( - r"(?P-*\d+.*\d*)*-(?P\d+.*\d*)*", diz["values"][0] + r"(?P-?(?:\d*\.)?\d+)?-(?P-?(?:\d*\.)?\d+)?", + diz["values"][0], ) if isrange: mn, mx = isrange.groups()