[Bf-extensions-cvs] [f8a16827] master: Fix T83671: OBJ Import: Ignore invalid lines (with 'command' but no data).

Jens noreply at git.blender.org
Tue Dec 15 12:15:39 CET 2020


Commit: f8a16827a2568088e5206e9d4432c5b57aae3eb5
Author: Jens
Date:   Tue Dec 15 12:11:41 2020 +0100
Branches: master
https://developer.blender.org/rBAf8a16827a2568088e5206e9d4432c5b57aae3eb5

Fix T83671: OBJ Import: Ignore invalid lines (with 'command' but no data).

OBJ files require that parameters are specified after every line start element except the "end" command.
This patch skips all lines that are missing that information unless there is a multi line context.

Reviewed By: mont29

Maniphest Tasks: T83671

Differential Revision: https://developer.blender.org/D9828

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

M	io_scene_obj/__init__.py
M	io_scene_obj/import_obj.py

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

diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index e20d50ea..df600bf1 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "Wavefront OBJ format",
     "author": "Campbell Barton, Bastien Montagne",
-    "version": (3, 8, 0),
+    "version": (3, 8, 1),
     "blender": (2, 81, 6),
     "location": "File > Import-Export",
     "description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index a303eda5..470e85ec 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -1025,6 +1025,10 @@ def load(context,
 
                 line_start = line_split[0]  # we compare with this a _lot_
 
+                if len(line_split) == 1 and not context_multi_line and line_start != b'end':
+                    print("WARNING, skipping malformatted line: %s" % line.decode('UTF-8', 'replace').rstrip())
+                    continue
+
                 # Handling vertex data are pretty similar, factorize that.
                 # Also, most OBJ files store all those on a single line, so try fast parsing for that first,
                 # and only fallback to full multi-line parsing when needed, this gives significant speed-up



More information about the Bf-extensions-cvs mailing list