Check proposed project names for problems

Today we discovered that Gitea doesn't allow creating projects with
"+" in their names (or that it needs special escaping in some way).
In order to avoid future incidents, let's be defensive and limit
organization/project names to only the characters which are
currently in use, since we know those work. If people want to use
characters outside that list in the future, we can test for
potential breakage before amending the filter.

Change-Id: I8b87ab6d52e0ec7da92f80a62c7d97e4f2245b29
This commit is contained in:
Jeremy Stanley 2023-10-12 13:34:14 +00:00
parent 80711d4d41
commit 1c0f48cae1

View File

@ -180,6 +180,18 @@ def main():
continue continue
if args.verbose: if args.verbose:
print('Checking %s' % name) print('Checking %s' % name)
if not re.match(r'[^/]+/[^/]+', name):
# name must have one and only one slash
found_errors += 1
print(
"ERROR: Project %s must have one and only one slash (/)"
% name)
if re.search(r'[^A-Za-z0-9./_-]', name):
# name can only consist of the characters A-Za-z0-9./_-
found_errors += 1
print(
"ERROR: Project %s has characters outside A-Za-z0-9./_-"
% name)
description = p.get('description') description = p.get('description')
# *very* simple check for common description mistakes # *very* simple check for common description mistakes