Skip to content

Commit

Permalink
Disallow creating project with " in the path
Browse files Browse the repository at this point in the history
It's not supported by dynamips.

Fix GNS3/gns3-gui#987
  • Loading branch information
julien-duponchelle committed Feb 4, 2016
1 parent 4f61443 commit 5bee927
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gns3server/modules/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def path(self, path):

if hasattr(self, "_path"):
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._update_temporary_file()
Expand Down
7 changes: 7 additions & 0 deletions tests/modules/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def test_changing_path_not_allowed(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):
p = Project()
assert p.__json__() == {"name": p.name, "location": p.location, "path": p.path, "project_id": p.id, "temporary": False}
Expand Down

0 comments on commit 5bee927

Please sign in to comment.