Skip to content

Commit

Permalink
Better error message if new VM Name starts with illegal characters
Browse files Browse the repository at this point in the history
  • Loading branch information
alimirjamali committed Jul 5, 2024
1 parent 3362ffc commit 053e3a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qubes/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def validate_name(holder, prop, value):
raise qubes.exc.QubesValueError(
'VM name must be shorter than 32 characters')

if re.match(r"\A[0-9_-]*\Z", value) is not None:
if holder is not None and prop is not None:
raise qubes.exc.QubesPropertyValueError(holder, prop, value,
'VM name cannot start with hyphen, underscore '
'or numbers'.format(prop.__name__))

# this regexp does not contain '+'; if it had it, we should specifically
# disallow 'lost+found' #1440
if re.match(r"\A[a-zA-Z][a-zA-Z0-9_-]*\Z", value) is None:
Expand Down

0 comments on commit 053e3a6

Please sign in to comment.