jp (blog/edit): do not remove files if they are not in the temporary dir hierarchy
This commit is contained in:
parent
c3ae32be42
commit
c951dea64b
1 changed files with 6 additions and 0 deletions
|
|
@ -116,6 +116,9 @@ class BlogCommon(object):
|
|||
"""
|
||||
if not os.path.isfile(path):
|
||||
raise OSError(u"path must link to a regular file")
|
||||
if not path.startswith(self.getTmpDir(sat_conf)):
|
||||
self.disp(u"File {} is not in blog temporary hierarchy, we do not remove it".format(path.decode('utf-8')), 2)
|
||||
return
|
||||
backup_dir = self.getTmpDir(sat_conf, SECURE_UNLINK_DIR)
|
||||
if not os.path.exists(backup_dir):
|
||||
os.makedirs(backup_dir)
|
||||
|
|
@ -311,6 +314,9 @@ class Edit(base.CommandBase, BlogCommon):
|
|||
|
||||
if len(content) == 0:
|
||||
self.disp(u"Content is empty, cancelling the blog edition")
|
||||
if not content_file_path.startswith(self.getTmpDir(sat_conf)):
|
||||
self.disp(u"File are not in blog temporary hierarchy, we do not remove it", 2)
|
||||
self.host.quit()
|
||||
self.disp(u"Deletion of {}".format(content_file_path.decode('utf-8')), 2)
|
||||
os.unlink(content_file_path)
|
||||
self.disp(u"Deletion of {}".format(meta_file_path.decode('utf-8')), 2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue