From dd77bc380e5ce0c5d9cb34e236a61837aea66261 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 8 May 2024 15:26:59 +0200 Subject: 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. --- ogcp/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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, -- cgit v1.2.3-18-g5258