1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Disallow creating project with " in the path

It's not supported by dynamips.

Fix https://github.com/GNS3/gns3-gui/issues/987
This commit is contained in:
Julien Duponchelle 2016-02-04 11:46:05 +01:00
parent 4f61443b20
commit 5bee927481
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D
2 changed files with 11 additions and 1 deletions

View File

@ -141,7 +141,10 @@ class Project:
if hasattr(self, "_path"): if hasattr(self, "_path"):
if path != self._path and self.is_local() is False: if path != self._path and self.is_local() is False:
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location") raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory path")
if '"' in path:
raise aiohttp.web.HTTPForbidden(text="You are not allowed to use \" in the project directory path. It's not supported by Dynamips.")
self._path = path self._path = path
self._update_temporary_file() self._update_temporary_file()

View File

@ -102,6 +102,13 @@ def test_changing_path_not_allowed(tmpdir):
p.path = str(tmpdir) p.path = str(tmpdir)
def test_changing_path_with_quote_not_allowed(tmpdir):
with patch("gns3server.modules.project.Project.is_local", return_value=True):
with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project()
p.path = str(tmpdir / "project\"53")
def test_json(tmpdir): def test_json(tmpdir):
p = Project() p = Project()
assert p.__json__() == {"name": p.name, "location": p.location, "path": p.path, "project_id": p.id, "temporary": False} assert p.__json__() == {"name": p.name, "location": p.location, "path": p.path, "project_id": p.id, "temporary": False}