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!
This commit is contained in:
Bastien Montagne 2019-06-27 13:53:22 +02:00
parent efc0fa6c4d
commit aba2d524a3
2 changed files with 3 additions and 1 deletions

View File

@ -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",

View File

@ -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')