views: report error when spaces are found in image name

Validate imagen names in POST /action/image/create.
Remove spaces at the begining and end of the image name, then
report error if the image name still contains space characters.
master
Alejandro Sirgo Rica 2024-05-08 15:26:59 +02:00
parent 6f488ae251
commit dd77bc380e
1 changed files with 6 additions and 1 deletions

View File

@ -1683,12 +1683,17 @@ def action_image_create():
if r.status_code != requests.codes.ok:
return ogserver_error('commands')
image_name = form.name.data.strip()
if ' ' in image_name:
flash(_('No spaces allowed in image names'), category='error')
return redirect(url_for('commands'))
disk, partition, code = form.os.data.split(' ')
payload = {"clients": [ip],
"disk": disk,
"partition": partition,
"code": code,
"name": form.name.data,
"name": image_name,
"repository_id": int(form.repository.data),
"id": "0", # This is ignored by the server.
"description": form.description.data,