1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-13 20:08:55 +00:00

Raise an error if you put an invalid key in node name

Fix https://github.com/GNS3/gns3-gui/issues/1833
This commit is contained in:
Julien Duponchelle 2017-02-06 15:05:29 +01:00
parent 0d7157c295
commit 9c7d2e9915
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -289,7 +289,10 @@ class Project:
if '{0}' in base_name or '{id}' in base_name:
# base name is a template, replace {0} or {id} by an unique identifier
for number in range(1, 1000000):
name = base_name.format(number, id=number, name="Node")
try:
name = base_name.format(number, id=number, name="Node")
except KeyError as e:
raise aiohttp.web.HTTPConflict(text="{" + e.args[0] + "} is not a valid replacement string in the node name")
if name not in self._allocated_node_names:
self._allocated_node_names.add(name)
return name