[Bf-extensions-cvs] [aba2d524] master: Fix potential issues with absolute-like paths in expected-relative properties.

Bastien Montagne noreply at git.blender.org
Thu Jun 27 13:55:52 CEST 2019


Commit: aba2d524a3aa1bfdd00e096fc89d75edb395cbe4
Author: Bastien Montagne
Date:   Thu Jun 27 13:53:22 2019 +0200
Branches: master
https://developer.blender.org/rBAaba2d524a3aa1bfdd00e096fc89d75edb395cbe4

Fix potential issues with absolute-like paths in expected-relative properties.

Relative filepath having a 'absolute look' (starting with a path
separator) can lead to recursively checking for the whole root!

This is nasty, so try to avoid it by making relative paths actually
relative.

Based on D5143 (report and patch) by andreas atteneder (@atti), thanks!

===================================================================

M	io_scene_fbx/__init__.py
M	io_scene_fbx/import_fbx.py

===================================================================

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index fb0c4213..2ed54a8a 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "FBX format",
     "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
-    "version": (4, 14, 13),
+    "version": (4, 14, 14),
     "blender": (2, 80, 0),
     "location": "File > Import-Export",
     "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 5957f837..d94a237c 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1408,6 +1408,8 @@ def blen_read_texture_image(fbx_tmpl, fbx_obj, basedir, settings):
     # Aaaaaaaarrrrrrrrgggggggggggg!!!!!!!!!!!!!!
     filepath = elem_find_first_string(fbx_obj, b'RelativeFilename')
     if filepath:
+        # Make sure we do handle a relative path, and not an absolute one (see D5143).
+        filepath = filepath.lstrip(os.path.sep).lstrip(os.path.altsep)
         filepath = os.path.join(basedir, filepath)
     else:
         filepath = elem_find_first_string(fbx_obj, b'FileName')



More information about the Bf-extensions-cvs mailing list