From b6fd15785871c17ce87c24488048ed1280c2e6f3 Mon Sep 17 00:00:00 2001 From: Cedric Steiert Date: Sat, 20 Jul 2024 18:07:52 +0200 Subject: [PATCH] fix quote detection of multi-line VRMLscripts fixes https://projects.blender.org/blender/blender-addons/issues/101717, when VRML contains multi-line VRMLscript by adding back the clsoing quoatation if the number of quotes is odd. Now the attached file imports correctly. --- source/import_x3d.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/import_x3d.py b/source/import_x3d.py index 4c21551..7065d72 100644 --- a/source/import_x3d.py +++ b/source/import_x3d.py @@ -714,7 +714,7 @@ class vrmlNode(object): for v in f: if v != ',': try: - ret.append(float(v)) + ret.append(float(v.strip('"'))) except: break # quit of first non float, perhaps its a new field name on the same line? - if so we are going to ignore it :/ TODO # print(ret) @@ -1218,6 +1218,11 @@ class vrmlNode(object): else: value += '\n' + l + # append a final quote if it is not there, like it's e.g. the case with multiline javascripts (#101717) + quote_count = l.count('"') + if quote_count % 2: # odd number? + value += '"' + # use shlex so we get '"a b" "b v"' --> '"a b"', '"b v"' value_all = shlex.split(value, posix=False) -- 2.30.2