Univention Bugzilla – Bug 53796
Broken UDM syntax dnsName_umlauts for computers/windows
Last modified: 2021-09-15 22:51:17 CEST
The syntax class dnsName_umlauts is still broken / or doesn't match its error message: >>> univention.admin.syntax.dnsName_umlauts.parse('''foo-bar''') 'foo-bar' >>> univention.admin.syntax.dnsName_umlauts.parse('''foo_bar''') 'foo_bar' >>> univention.admin.syntax.dnsName_umlauts.parse('''foo.bar''') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/univention/admin/syntax.py", line 227, in parse raise univention.admin.uexceptions.valueError(self.error_message) univention.admin.uexceptions.valueError: A host name or FQDN must start and end with a letter or number. In between additionally dashes, dots and underscores are allowed. +++ This bug was initially created as a clone of Bug #35041 +++ The UDM syntax univention.admin.syntax.dnsName_umlauts is (amongst others) used in the UDM module computers/windows.py for checking hostnames seems to be broken. class dnsName_umlauts(simple): regex = re.compile('(?u)(^\w[\w -.]*\w$)|\w*$') >>> regex = re.compile('(?u)^\w[\w -.]*\w$') >>> regex.match('''foo ( - " , ' _ ) bar''') <_sre.SRE_Match object at 0x29176b0> >>> regex.match(u'''foo ( - " ä , ü ' _ ) bar''') <_sre.SRE_Match object at 0x2917850> The part " -." specifies a character range which contains all characters between space and dot (e.g. ()"'-, ). So this does not look ok to me. Side note: the second alternative "\w*$" of the regex should use ^ otherwise it would match to any string if re.search() is used instead of re.match().