Fix "span" regex

This disallows matching "0-11-2" and "1," for example. It also avoids an exponential backtracking issue which could make this regex very slow.
This commit is contained in:
Gunter Labes 2024-06-03 18:54:52 +02:00
parent a7483313d9
commit 28a8959854

View file

@ -486,7 +486,7 @@ def actualtype(a):
atype = "percentage" atype = "percentage"
elif re.match(r"-?[0-9]+,-?[0-9]+\Z", a): elif re.match(r"-?[0-9]+,-?[0-9]+\Z", a):
atype = "position" atype = "position"
elif re.match(r"([0-9]+\-[0-9]+,?|[0-9]+,?)+\Z", a): elif re.match(r"(([0-9]+-)?[0-9]+,)*([0-9]+-)?[0-9]+\Z", a):
atype = "span" atype = "span"
elif a in ("melee", "ranged"): elif a in ("melee", "ranged"):
atype = "range" atype = "range"