file_manager: require base paths be located within home directory

They however cannot be the home directory.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-08-11 20:31:07 -04:00
parent b3f02a73a4
commit 2c332a968f
1 changed files with 5 additions and 1 deletions

View File

@ -88,8 +88,12 @@ class FileManager:
op_check_cb = self._handle_operation_check
if path is None:
return False
home = os.path.expanduser('~')
path = os.path.normpath(os.path.expanduser(path))
if not os.path.isdir(path):
if not os.path.isdir(path) or not path.startswith(home) or \
path == home:
logging.info(
f"Supplied path ({path}) for ({base}) not valid")
return False
if path != self.file_paths.get(base, ""):
self.file_paths[base] = path