Bug 53796 - Broken UDM syntax dnsName_umlauts for computers/windows
Broken UDM syntax dnsName_umlauts for computers/windows
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on: 35041
Blocks:
  Show dependency treegraph
 
Reported: 2021-09-15 22:51 CEST by Florian Best
Modified: 2021-09-15 22:51 CEST (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2021-09-15 22:51:10 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().