From 80cfaeca0954b51d950a5cb27312768a7a99af50 Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Thu, 22 Sep 2016 16:55:38 +0200
Subject: [PATCH] Fix T49412: We do not support FBX 7500 and above, at least
 properly report it to users.

Those ... people? at AD changed the whole format on binary level it'd seem, even low-level,
binary parsing is broken with those files, nothing else to do but go back to
binary hacking/inspection of new files if we want to support them... will let that
to someone else, FBX has successfully exhausted my patience since years already,
even all the backup emergency reserves I had.
---
 io_scene_fbx/__init__.py   | 2 +-
 io_scene_fbx/fbx2json.py   | 2 ++
 io_scene_fbx/import_fbx.py | 4 ++--
 io_scene_fbx/parse_fbx.py  | 2 ++
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index e9180ea27..661955bc1 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": (3, 7, 6),
+    "version": (3, 7, 7),
     "blender": (2, 77, 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/fbx2json.py b/io_scene_fbx/fbx2json.py
index 68ceb5b2d..21b0fcc70 100755
--- a/io_scene_fbx/fbx2json.py
+++ b/io_scene_fbx/fbx2json.py
@@ -198,6 +198,8 @@ def parse(fn, use_namedtuple=True):
             raise IOError("Invalid header")
 
         fbx_version = read_uint(read)
+        if fbx_version >= 7500:
+            raise IOError("Unsupported FBX version (%d), binary format is incompatible!" % fbx_version)
 
         while True:
             elem = read_elem(read, tell, use_namedtuple)
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 75a8db65d..46cef68a1 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -2250,11 +2250,11 @@ def load(operator, context, filepath="",
 
     try:
         elem_root, version = parse_fbx.parse(filepath)
-    except:
+    except Exception as e:
         import traceback
         traceback.print_exc()
 
-        operator.report({'ERROR'}, "Couldn't open file %r" % filepath)
+        operator.report({'ERROR'}, "Couldn't open file %r (%s)" % (filepath, e))
         return {'CANCELLED'}
 
     if version < 7100:
diff --git a/io_scene_fbx/parse_fbx.py b/io_scene_fbx/parse_fbx.py
index 87f8624ff..220d88e0a 100644
--- a/io_scene_fbx/parse_fbx.py
+++ b/io_scene_fbx/parse_fbx.py
@@ -159,6 +159,8 @@ def parse(fn, use_namedtuple=True):
             raise IOError("Invalid header")
 
         fbx_version = read_uint(read)
+        if fbx_version >= 7500:
+            raise IOError("Unsupported FBX version (%d), binary format is incompatible!" % fbx_version)
 
         while True:
             elem = read_elem(read, tell, use_namedtuple)
-- 
GitLab