Skip to content

Commit

Permalink
use regex
Browse files Browse the repository at this point in the history
  • Loading branch information
12944qwerty committed Sep 28, 2023
1 parent da40202 commit f460971
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import Enum
from pathlib import Path
from typing import *
import re

import click
from semantic_version import Spec, Version
Expand Down Expand Up @@ -282,10 +283,9 @@ def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Pro
self.is_beta = kwargs.get('beta', False)
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}\''))
if re.match(r'^[\w\-. /]+$', str(Path(path))) is None:
raise dont_send(ValueError('Invalid characters found in path'))

proj = Project(path=path, create=True)
if 'target' in kwargs:
proj.target = kwargs['target']
Expand Down

0 comments on commit f460971

Please sign in to comment.