[FIX] tools: verify path before opening

This commit is contained in:
Olivier Dony 2017-06-02 22:29:47 +02:00
parent d0301459ae
commit d18d606a55
No known key found for this signature in database
GPG Key ID: CD556E25E8A6D0D4
1 changed files with 10 additions and 1 deletions

View File

@ -205,7 +205,16 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False):
def _fileopen(path, mode, basedir, pathinfo, basename=None):
name = os.path.normpath(os.path.join(basedir, path))
name = os.path.normpath(os.path.normcase(os.path.join(basedir, path)))
import openerp.modules as addons
paths = addons.module.ad_paths + [config['root_path']]
for addons_path in paths:
addons_path = os.path.normpath(os.path.normcase(addons_path)) + os.sep
if name.startswith(addons_path):
break
else:
raise ValueError("Unknown path: %s" % name)
if basename is None:
basename = name