model.base: fix id_short validation
Compare changes
+ 2
− 2
@@ -461,9 +461,9 @@ class Referable(metaclass=abc.ABCMeta):
Aufgrund einer Wartung am 24.06.2025 von 8:00 bis 09:00 Uhr werden git.rwth-aachen.de & git-ce.rwth-aachen.de zeitweise nicht zur Verfügung stehen.
--
Due to maintenance at 24.06.2025 from 8:00 to 09:00, git.rwth-aachen.de & git-ce.rwth-aachen.de will be temporarily unavailable.
This commit backports 445b1d8f from fix/id_short_validation (!78 (merged)).
In RegEx, the $
asserts the end of a string or line. When used in
re.match() it asserts the end of the string by default, unless the last
character is a newline symbol (\n
). Then it asserts the end of the string
before the newline. Thus the first regex check doesn't filter valid
id_shorts ending in a newline, which it should.
See https://docs.python.org/3.9/library/re.html#index-2
Using re.fullmatch() instead fixes this issue, making the ^
and $
unnecessary as well.
Next to adding a test for this behaviour this commit also simplifies the check for an alphabetical character at the start of the id_short. And although both checks could also be merged into one, they are left separate to be able to report more accurate errors.