From aa3c5a1cadccbaa9caaa95e0a0caf68c10ae31f0 Mon Sep 17 00:00:00 2001 From: Frank Galligan Date: Mon, 13 Jan 2020 15:06:56 -0800 Subject: [PATCH] Fix loading images with spaces on Linux This change quotes the string before it is passed into wordexp. This addresses issue https://github.com/syoyo/tinygltf/issues/236 --- .../ 2x2 image has multiple spaces.png | Bin 0 -> 79 bytes .../2x2 image has spaces.png | Bin 0 -> 79 bytes .../CubeImageUriMultipleSpaces.gltf | 171 ++++++++++++++++++ .../CubeImageUriSpaces/CubeImageUriSpaces.bin | Bin 0 -> 804 bytes .../CubeImageUriSpaces.gltf | 171 ++++++++++++++++++ tests/tester.cc | 26 +++ tiny_gltf.h | 4 +- 7 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 models/CubeImageUriSpaces/ 2x2 image has multiple spaces.png create mode 100644 models/CubeImageUriSpaces/2x2 image has spaces.png create mode 100644 models/CubeImageUriSpaces/CubeImageUriMultipleSpaces.gltf create mode 100644 models/CubeImageUriSpaces/CubeImageUriSpaces.bin create mode 100644 models/CubeImageUriSpaces/CubeImageUriSpaces.gltf diff --git a/models/CubeImageUriSpaces/ 2x2 image has multiple spaces.png b/models/CubeImageUriSpaces/ 2x2 image has multiple spaces.png new file mode 100644 index 0000000000000000000000000000000000000000..67d8040da398071e257745c9fbd6b0e50f38ac3e GIT binary patch literal 79 zcmeAS@N?(olHy`uVBq!ia0vp^Od!kwBL7~QRScxWJY5_^IIbt}IDFv1>Ag*kX{_IW b$FE_Ka%72`@Y|^osDi=M)z4*}Q$iB}^U)UT literal 0 HcmV?d00001 diff --git a/models/CubeImageUriSpaces/2x2 image has spaces.png b/models/CubeImageUriSpaces/2x2 image has spaces.png new file mode 100644 index 0000000000000000000000000000000000000000..67d8040da398071e257745c9fbd6b0e50f38ac3e GIT binary patch literal 79 zcmeAS@N?(olHy`uVBq!ia0vp^Od!kwBL7~QRScxWJY5_^IIbt}IDFv1>Ag*kX{_IW b$FE_Ka%72`@Y|^osDi=M)z4*}Q$iB}^U)UT literal 0 HcmV?d00001 diff --git a/models/CubeImageUriSpaces/CubeImageUriMultipleSpaces.gltf b/models/CubeImageUriSpaces/CubeImageUriMultipleSpaces.gltf new file mode 100644 index 0000000..49d32ec --- /dev/null +++ b/models/CubeImageUriSpaces/CubeImageUriMultipleSpaces.gltf @@ -0,0 +1,171 @@ +{ + "asset": { + "version": "2.0" + }, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ], + "scene": 0, + "nodes": [ + { + "mesh": 0 + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "NORMAL": 2, + "POSITION": 1, + "TEXCOORD_0": 3 + }, + "indices": 0, + "mode": 4, + "material": 0 + } + ] + } + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorTexture": { + "index": 0, + "texCoord": 0 + }, + "baseColorFactor": [ + 1, + 1, + 1, + 1 + ], + "metallicFactor": 1, + "roughnessFactor": 1 + }, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE" + } + ], + "textures": [ + { + "source": 0, + "sampler": 0 + } + ], + "samplers": [ + { + "wrapS": 33071, + "wrapT": 33071 + } + ], + "images": [ + { + "uri": " 2x2 image has multiple spaces.png " + } + ], + "accessors": [ + { + "bufferView": 0, + "byteOffset": 0, + "componentType": 5121, + "count": 36, + "normalized": false, + "max": [ + 23 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 1, + "byteOffset": 0, + "componentType": 5126, + "count": 24, + "normalized": false, + "max": [ + 0.5, + 0.5, + 0.5 + ], + "min": [ + -0.5, + -0.5, + -0.5 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 0, + "componentType": 5126, + "count": 24, + "normalized": false, + "max": [ + 1, + 1, + 1 + ], + "min": [ + -1, + -1, + -1 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 0, + "componentType": 5126, + "count": 24, + "normalized": false, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteOffset": 0, + "byteLength": 36 + }, + { + "buffer": 0, + "byteOffset": 36, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 324, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 612, + "byteLength": 192 + } + ], + "buffers": [ + { + "byteLength": 804, + "uri": "CubeImageUriSpaces.bin" + } + ] +} diff --git a/models/CubeImageUriSpaces/CubeImageUriSpaces.bin b/models/CubeImageUriSpaces/CubeImageUriSpaces.bin new file mode 100644 index 0000000000000000000000000000000000000000..20598674468b499a36efb07ea0d8e8630903261f GIT binary patch literal 804 zcmb780SDZePpRIo6lZ`8nc{%+Ujo> zDnLtB;w8^}4=v#DRC|2S#~RJV`N!MS2@!NhiT~p<3nY*C$?SPvMsKB0