1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 15:45:23 +00:00

instances/views.py check instance name, alloweed r^[a-zA-Z0-9-]+$

This commit is contained in:
Ing. Jan KRCMAR 2016-09-06 13:01:45 +02:00
parent 08cc19900c
commit 525d42a74d

View file

@ -3,6 +3,7 @@ import time
import json import json
import socket import socket
import crypt import crypt
import re
from string import letters, digits from string import letters, digits
from random import choice from random import choice
from bisect import insort from bisect import insort
@ -610,6 +611,9 @@ def instance(request, compute_id, vname):
elif check_instance: elif check_instance:
msg = _("Instance '%s' already exists!" % clone_data['name']) msg = _("Instance '%s' already exists!" % clone_data['name'])
error_messages.append(msg) error_messages.append(msg)
elif not re.match(r'^[a-zA-Z0-9-]+$', clone_data['name']):
msg = _("Instance name '%s' contains invalid characters!" % clone_data['name'])
error_messages.append(msg)
else: else:
for post in request.POST: for post in request.POST:
clone_data[post] = request.POST.get(post, '') clone_data[post] = request.POST.get(post, '')