From 3ee2cb0414662d5da4c1bf0dc794d70a26855f49 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Thu, 22 Aug 2019 13:07:03 -0500 Subject: [PATCH] check that path is within root folder of set --- .../resource.language.en_gb/strings.po | 4 ++++ resources/lib/advanced_editor.py | 20 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 21d9f54..238ed6d 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -531,4 +531,8 @@ msgstr "" msgctxt "#30135" msgid "Add Include Folder" +msgstr "" + +msgctxt "#30136" +msgid "Path must be within root folder" msgstr "" \ No newline at end of file diff --git a/resources/lib/advanced_editor.py b/resources/lib/advanced_editor.py index 9da932b..968c300 100644 --- a/resources/lib/advanced_editor.py +++ b/resources/lib/advanced_editor.py @@ -78,6 +78,9 @@ class AdvancedBackupEditor: def _cleanPath(self,root,path): return path[len(root)-1:] + def _validatePath(self,root,path): + return path.startswith(root) + def createSet(self): backupSet = None @@ -127,13 +130,16 @@ class AdvancedBackupEditor: #add a folder, will equal root if cancel is hit addFolder = self.dialog.browse(type=0,heading=utils.getString(30120),shares='files',defaultt=backupSet['root']) - #cannot add root as an exclusion - if(optionSelected == 0 and addFolder != backupSet['root']): - backupSet['dirs'].append({"path":addFolder,"type":"exclude"}) - elif(optionSelected == 1): - #can add root as inclusion - backupSet['dirs'].append({"path":addFolder,"type":"include","recurse":True}) - + if(addFolder.startswith(rootPath)): + #cannot add root as an exclusion + if(optionSelected == 0 and addFolder != backupSet['root']): + backupSet['dirs'].append({"path":addFolder,"type":"exclude"}) + elif(optionSelected == 1): + #can add root as inclusion + backupSet['dirs'].append({"path":addFolder,"type":"include","recurse":True}) + else: + #folder must be under root folder + self.dialog.ok(utils.getString(30117), utils.getString(30136),rootPath) elif(optionSelected == 2): self.dialog.ok(utils.getString(30121),utils.getString(30130),backupSet['root']) elif(optionSelected > 2):