From 39a05b081f94b816a9b6c82da18eeb828b01d154 Mon Sep 17 00:00:00 2001 From: Ayush Shukla <71904196+ayushuk@users.noreply.github.com> Date: Mon, 17 Apr 2023 18:05:03 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8No=20invalid=20characters=20in=20new?= =?UTF-8?q?=20project=20directory=20name=20(#278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added check for valid directory name when creating a project * Removed pyinstaller from requirements.txt * Revert "Removed pyinstaller from requirements.txt" This reverts commit ea02936a15c563d5dd3865315a058126d165b33a. * Revert "Added check for valid directory name when creating a project" This reverts commit d4ec1635948a01e202e685ec61100a34a26d85aa. * Added check for invalid new project directory name * Added check for invalid directory characters * Added check for non-ASCII characters --------- Co-authored-by: Andrew Chen Co-authored-by: Andrew Chen --- pros/conductor/conductor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pros/conductor/conductor.py b/pros/conductor/conductor.py index ebe3f43a..35360770 100644 --- a/pros/conductor/conductor.py +++ b/pros/conductor/conductor.py @@ -215,6 +215,10 @@ def remove_template(project: Project, identifier: Union[str, BaseTemplate], remo def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Project: if Path(path).exists() and Path(path).samefile(os.path.expanduser('~')): raise dont_send(ValueError('Will not create a project in user home directory')) + for char in str(Path(path)): + if char in ['/', '?', '<', '>', '\\', ':', '*', '|', '^', '#', '%', '&', '$', '+', '!', '`', '\'', '=', + '@', '\'', '{', '}', '[', ']', '(', ')', '~'] or ord(char) > 127: + raise dont_send(ValueError(f'Invalid character found in directory name: \'{char}\'')) proj = Project(path=path, create=True) if 'target' in kwargs: proj.target = kwargs['target']