Added check to BaseImporter::SearchFileHeaderForToken making sure that a detected token is not in fact just a fraction of a longer token. Microsoft exported binary gltf files were detected as OBJ, because the "gltf " in the string "Microsoft GLTF Exporter 2.4.1.7" was detected as the token "f ". I added a new bool parameter to the method enabling this check. It's default false, and only ObjFileImporter sets it to true, so no other code should be affected.

This commit is contained in:
Max Vollmer
2018-06-25 12:05:37 +02:00
parent dddf33d394
commit 52c017b595
3 changed files with 10 additions and 3 deletions

View File

@@ -100,7 +100,7 @@ bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler ,
} else {
// Check file Header
static const char *pTokens[] = { "mtllib", "usemtl", "v ", "vt ", "vn ", "o ", "g ", "s ", "f " };
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9 );
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9, 200, false, true );
}
}