summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-08 15:26:59 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-09 09:27:19 +0200
commitdd77bc380e5ce0c5d9cb34e236a61837aea66261 (patch)
treec747a1593f239916f5f94e5aab54c75bd5f6c242
parent6f488ae25173408c2f27acdbc25dce56aa84ef23 (diff)
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.
-rw-r--r--ogcp/views.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index fe3902b..131686c 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -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,