diff --git a/tests/issue-416.gltf b/tests/issue-416.gltf new file mode 100644 index 0000000..f1244ab --- /dev/null +++ b/tests/issue-416.gltf @@ -0,0 +1 @@ +{"images":[{"uri":"%!QAAAQAAA5"}],"asset":{"version":""}} diff --git a/tests/tester.cc b/tests/tester.cc index 6d93d28..8ebeeae 100644 --- a/tests/tester.cc +++ b/tests/tester.cc @@ -738,3 +738,22 @@ TEST_CASE("filesize-check", "[issue-416]") { REQUIRE(false == ret); } + +TEST_CASE("load-issue-416-model", "[issue-416]") { + + tinygltf::Model model; + tinygltf::TinyGLTF ctx; + std::string err; + std::string warn; + + bool ret = ctx.LoadASCIIFromFile(&model, &err, &warn, "issue-416.gltf"); + if (!warn.empty()) { + std::cout << "WARN:" << warn << std::endl; + } + if (!err.empty()) { + std::cerr << "ERR:" << err << std::endl; + } + + // external file load fails, but reading glTF itself is ok. + REQUIRE(true == ret); +} diff --git a/tiny_gltf.h b/tiny_gltf.h index 4f2f079..9e1351b 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -4177,8 +4177,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err, if (!uri_cb->decode(uri, &decoded_uri, uri_cb->user_data)) { if (warn) { (*warn) += "Failed to decode 'uri' for image[" + - std::to_string(image_idx) + "] name = [" + image->name + - "]\n"; + std::to_string(image_idx) + "] name = \"" + image->name + + "\"\n"; } // Image loading failure is not critical to overall gltf loading. @@ -4190,8 +4190,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err, /* checksize */ false, /* max file size */ max_file_size, fs)) { if (warn) { (*warn) += "Failed to load external 'uri' for image[" + - std::to_string(image_idx) + "] name = [" + decoded_uri + - "]\n"; + std::to_string(image_idx) + "] name = \"" + decoded_uri + + "\"\n"; } // If the image cannot be loaded, keep uri as image->uri. return true; @@ -4200,8 +4200,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err, if (img.empty()) { if (warn) { (*warn) += "Image data is empty for image[" + - std::to_string(image_idx) + "] name = [" + image->name + - "] \n"; + std::to_string(image_idx) + "] name = \"" + image->name + + "\" \n"; } return false; }