summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2017-06-02 22:13:36 +0200
committerOlivier Dony <odo@openerp.com>2017-06-02 22:13:36 +0200
commit76cd8d2558d2a1fc11681dbc4a134ba06fb698c0 (patch)
tree777a6b80d746b77287860c5c6fd9f775d6e02d20
parent380f59bd16254178881618bc5fb5b9f1bca0f2e8 (diff)
[FIX] tools: verify path before opening
-rw-r--r--odoo/tools/misc.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index 36061213003..c54af653a00 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -196,7 +196,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 odoo.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